简体   繁体   English

像mvc路由没有mvc的asp.net处理程序?

[英]asp.net handler like mvc routing without mvc?

I used to build my web apps in asp.net in such there is only one page witch is default.aspx 我曾经在asp.net中构建我的网络应用程序,这样只有一页,女巫是default.aspx

http://localhost/mywebapp1/?q=blog/posts/get/42

I do parse 'q' by myself and do all processing. 我自己解析'q'并进行所有处理。 I don't really need to all MVC staff. 我并不需要所有MVC员工。 I just want to remove "?q=" 我只想删除“?q =”

any idea? 任何的想法?

You can use ASP.NET Routing outside of ASP.NET MVC. 您可以在ASP.NET MVC之外使用ASP.NET路由。 This MSDN article explains how. 这篇 MSDN文章解释了如何。

If you're using IIS 7 (Windows 2008 / Vista or higher) you could use the IIS URL Rewrite module from http://www.iis.net/download/URLRewrite 如果您使用的是IIS 7(Windows 2008 / Vista或更高版本),则可以使用http://www.iis.net/download/URLRewrite中的IIS URL重写模块

You define the rules either in web.config or through the IIS front end. 您可以在web.config中或通过IIS前端定义规则。

For example I use the following for friendly URLS to shop items on my site. 例如,我使用以下友好URLS来购买我网站上的项目。

It makes mysite.com/shop/package-one to to mysite.com/shop/default.aspx?package=package-one 它使mysite.com/shop/package-one到mysite.com/shop/default.aspx?package=package-one

<rewrite>
  <rules>
    <rule name="ShopPackages" stopProcessing="true">
      <match url="^shop/(.*)"/>
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
      </conditions>
      <action type="Rewrite" url="/shop/default.aspx?package={R:1}" appendQueryString="false"/>
    </rule>
  </rules>
</rewrite> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM