在重写的URL ASP.NET? [英] Rewriting URLs in ASP.NET?

查看:125
本文介绍了在重写的URL ASP.NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ASP.NET C#。

I am using ASP.NET C#.

我如何实现URL重写的过程,类似于StackOverflow.com?

How do I implement URL re-writing procedure that is similar to StackOverflow.com?

http://stackoverflow.com/questions/358630/how-to-search-date-in-sql

此外,什么是在URL值,如358630的含义?这就是问题的ID(它们用来从表中的数据的基础)?不管是什么,在我的应用我确定使用的是ID字段记录。该字段是SQL表标识列。现在,我的网址是这样的:

Also, what is the meaning of values such as "358630" in the URL? Is this the question ID (the basis for which they use to fetch the data from the table)? Whatever it is, in my application I am identifying records using an "ID" field. This field is an identity column in an SQL table. Right now, my URLs are like the following:

http://myweb.com/showdetails.aspx?id=9872

不过,我希望他们看起来像:

But I'd like them to appear like:

http://myweb.com/showdetails/9872/my_question_title

或者

http://myweb.com/9872/my_question_title

或任何最好的方式,这将口感好搜索机器人。

Or whatever the best way, which will taste good to search bots.

我的应用程序托管在的的Go Daddy 共享托管服务,我觉得没有定制ASP.NETHTTP模块或URL重写任何定制DLL正在自己的服务器上。我试过很多样,但没有运气呢!

My application is hosted on Go Daddy's shared hosting service, and I feel that no customized ASP.NET "HTTP module" or no customized DLL for URL re-writing is working on their server. I tried many samples but no luck yet!

我发现堆栈溢出是在去爸爸托管(共享主机?)。也许堆栈溢出的方法为我工作。

I found that Stack Overflow is hosted on Go Daddy (shared hosting?). Maybe Stack Overflow's method will work for me.

推荐答案

所以使用 ASP.NET MVC 。你真的需要详细阅读MVC URL如何重写的作品,但它的要点是,问题中的URL部分是控制器类的名称(这大致相当于你的URL中的'showdetails')和数字是在该控制器(等同于你的URL参数ID)默认操作的ID参数。

SO is using ASP.NET MVC. You really need to read in details how MVC URL rewriting works, but the gist of it is that the 'questions' part in the URL is the name of the Controller class (which roughly corresponds to the 'showdetails' in your URL) and the number is a ID parameter for the default action on that Controller (same as the parameter 'id' in your URL).

这篇关于在重写的URL ASP.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆