C# ASP.NET 4.0 中的 URL 重写
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14274370/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
URL Rewriting in ASP.NET 4.0
提问by Arry
Possible Duplicate:
ASP.NET 4.0 URL Rewriting: How to deal with the IDs
I am trying to do url re-writing in my asp.net c# project, and I searched internet but did not get what I was looking for.
我正在尝试在我的 asp.net c# 项目中重写 url,并且我搜索了互联网但没有得到我想要的。
Say, for example I have following url:
说,例如我有以下网址:
http://www.example.com/Question.aspx?qid=1
Now, Question.aspx finds a question against (which has title and body field) for qid from the db and displays it. I want to display question title in url.
现在,Question.aspx 从数据库中找到一个针对 qid 的问题(具有标题和正文字段)并显示它。我想在 url 中显示问题标题。
My requirement is something like this:
我的要求是这样的:
http://www.example.com/Question/1/QuestionTitleGoesHere
Can anyone please suggest that how can I achieve this ASP.NET 4.0?
任何人都可以建议我如何实现这个 ASP.NET 4.0?
回答by Srikanth Venugopalan
In IIS you can use Url Rewriteto achieve this.
在 IIS 中,您可以使用Url Rewrite来实现这一点。
If you need this to be within the application, could you look at using MVC3/MVC4 instead of webforms? If that is an option.
如果您需要在应用程序中使用它,您可以考虑使用 MVC3/MVC4 而不是 webforms 吗?如果这是一个选择。
回答by Jigar Pandya
You can check following working examples of URL Rewriting in asp.net web forms projects using
您可以使用以下方法在 asp.net web 表单项目中检查以下 URL 重写的工作示例
URL Rewriting using ASP.NET for SEO
回答by Rajpurohit
I think you should try these links:
我认为您应该尝试以下链接:
URL Routing with ASP.NET 4 Web Forms (VS 2010 and .NET 4.0 Series)
URL 路由与 ASP.NET 4 Web 窗体(VS 2010 和 .NET 4.0 系列)
They will help you.
他们会帮助你。