我可以在MSVS中重写URL吗?

时间:2022-11-24 00:25:47

I am using MSVS 2008, C#, ASP.NET project. Right now i can serve any pages i want under http://localhost:3288/ExistingPageInProject.aspx

我正在使用MSVS 2008,C#,ASP.NET项目。现在我可以在http:// localhost:3288 / ExistingPageInProject.aspx下提供我想要的任何页面

In MSVS how do i map http://localhost:3288/u/SOME_USER_NAME/media/TITLE-0123 to point to a file/page i have. Such as /u/ExamplePage?name=SOME_USER_NAME&title=TITLE-0123

在MSVS中,我如何映射http:// localhost:3288 / u / SOME_USER_NAME / media / TITLE-0123以指向我拥有的文件/页面。例如/ u / ExamplePage?name = SOME_USER_NAME&title = TITLE-0123

NOTE: 0123 is the mediaId so the title can be ignored.

注意:0123是mediaId,因此可以忽略标题。

1 个解决方案

#1


The way I personally do it is to use Application_BeginRequest in public class Global : System.Web.HttpApplication and parse the URL with Regex or whatever, and then use HttpContext.Current.RewritePath to serve the correct page without doing a redirect.

我个人这样做的方法是在公共类Global:System.Web.HttpApplication中使用Application_BeginRequest并使用Regex或其他任何方法解析URL,然后使用HttpContext.Current.RewritePath来提供正确的页面而不进行重定向。

There are also other ways to do it, but that's my preference and its easy to implement.

还有其他方法可以做到这一点,但这是我的偏好,也很容易实现。

#1


The way I personally do it is to use Application_BeginRequest in public class Global : System.Web.HttpApplication and parse the URL with Regex or whatever, and then use HttpContext.Current.RewritePath to serve the correct page without doing a redirect.

我个人这样做的方法是在公共类Global:System.Web.HttpApplication中使用Application_BeginRequest并使用Regex或其他任何方法解析URL,然后使用HttpContext.Current.RewritePath来提供正确的页面而不进行重定向。

There are also other ways to do it, but that's my preference and its easy to implement.

还有其他方法可以做到这一点,但这是我的偏好,也很容易实现。