How to apply custom url without using url-rewriting?
I am creating a dynamic website in asp.net based on content fetching from MSSQL DB. What I want to do is : everycontent has its own link/url based on contentId-Title. How can I do this?
Example: Table has : ID :1 Title : Mytitle Description :This is description Extension : .html Url :
Now, I need to show the all results in a datagrid with titl开发者_Python百科e link as:
Title : mytitle => Now whenever anybody clicks on it it will resolve in the form of : "/1-mytitle.html"
So, formula to create url is : ID-Title Extention for instance above will generate as :
<a href="/1-mytitle.html">MyTitle</a>
Such tasks can be implemented by creating a custom HttpHandler. For more details, please refer to the MSDN:
Serving Dynamic Content with HTTP Handlers
Check out routing, its a part of ASP.NET 3.5 SP 1 or later. It should be able to do what you need.
If you are somehow stuck on 2.0, you can fake the inbound parts of routing by using custom mapped http handler factories, but I can't think of a case where upgrading to 3.5 would not be more cost effective.
精彩评论