How to display query results in seperate page like Stack Overflow in asp.net
I'm making a small Forum where user can start topics and reply, it's just like bulletin board, I'm doing this asp.net project for le开发者_运维百科arning purpose, as I noticed in many forums or bulletin board they use separate pages, (actually I don't know how they achieve) to display result
for eg: How to read an external html page using jquery?
in that for every query " questions/6327018/how-to-read-an-external-html-page-using-jquery" this will be changed automatically based on the query, I don't know how to achieve this in asp.net.
if user select his topic, based on topic it has to show in separate page like above the stackoverflow eg ..
Stack overflow is written using MVC. Hence in the case of this posting you have a controller named "Questions" (the class is really named QuestionsController) that takes a parameter of "6333181" as an integer. Your route points to some method - generally named "Index". So in QuestionsController.cs you would have a method like:
public ActionResult Index(int postingId)
Note - the URL for this posting can be How to display query results in seperate page like Stack Overflow in asp.net without anything else.
In MVC this is quite simple and is designed this way out of the box. No url rewriting required, this is how you setup your routes in the global.asax.cs in an ASP.Net MVC application.
For stack overflow this can be confirmed here:
https://blog.stackoverflow.com/2008/09/what-was-stack-overflow-built-with/
The way that is achieved is using URL rewriting. Behind the scenes that url "questions/6327018/how-to-read-an-external-html-page-using-jquery" is redirected to something presumably like "questions.aspx?id=6327018".
That's the first step, you need to get your application to handle URL rewriting. It's pretty easy these days in IIS/ASP.NET, there's a built in extension so you can just set that up in your web.config.
The second step is using that id=[number] and querying the database for the data associated with the question with that id and displaying it on page.
精彩评论