0

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 title 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>
2
  • 2
    What do you mean "without using url-rewriting". You are specifically asking for url-rewriting. This question is ridiculous. Commented Sep 11, 2010 at 12:16
  • @Noon - First thanks for your words. As this is an open forum and there are many novice members who want to learn /know better so, if you are excellent in the field so, please do not use these kind of words "ridiculous". Anyways, I do not want to apply url-rewritting I mean to make fancy my dynamic urls I just want to use the link which were supplied in table. Commented Sep 11, 2010 at 12:55

2 Answers 2

1

Such tasks can be implemented by creating a custom HttpHandler. For more details, please refer to the MSDN:

Serving Dynamic Content with HTTP Handlers

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot for your assistant. But, there is bit difference as per requirement. There is only the way how we can handle different extensions. But in our case there is a customized url too. Also we need to access this information on virtual pages which are not exist physically. Words from you will be most appreciated.
You can check an url requested by implementing a new IHttpHandlerFactory. This information can be obtained using the context.Request object. Also, this approach implies that you have several templated pages whose compiled version is returned in the GetHandler method. Finally, you can save the page's identifier to the context.Items object and fetch it in the page's Load event. You will find an example on how this can be done in the same MSDN article.
0

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.

1 Comment

This is what I was wondering. Could you provide any reference article/link for the same?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.