开发者

ssl and rewrite tag does not recognized by visual studio in mvc3 web site web.config

开发者 https://www.devze.com 2023-03-25 01:59 出处:网络
I\'ve written a simple web application using asp.net mvc3 and I have a login page which control access to the site. Every request which is not authenticated will redirect to this page.

I've written a simple web application using asp.net mvc3 and I have a login page which control access to the site. Every request which is not authenticated will redirect to this page.

I want to use ssl to make the site secure (using https). I don't want to use https for all of my sites because it make it heavy for browsers. The problem is when I add following tags to web.config, VS2010 ultimate does not recognize it and does not work.

I have deployed the project to IIS 7.5 too but it does not work either. what should I do?

  <system.webServer>
<rewrite>
  <rule na开发者_Python百科me="Redirect to HTTP">
    <match url="secureDir/(.*)" negate="true" />
    <conditions>
      <add input="{HTTPS}" pattern="^ON$" />
    </conditions>
    <action type="Redirect" url="http://{HTTP_HOST}{REQUEST_URI}" />
  </rule>

  <rule name="Redirect to HTTPS" stopProcessing="true">
    <match url="secureDir/(.*)" />
    <conditions>
      <add input="{HTTPS}" pattern="^OFF$" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" />
  </rule>
</rewrite>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
 </system.webServer>


You'll need the URL Rewrite extension for IIS and the rewrite tag only works with IIS, so you'll need to be using that for your project. You don't neccesarily need VS to validate your xml if it's correct, but if you want it, there's a guide here: http://ruslany.net/2010/04/visual-studio-xml-intellisense-for-url-rewrite-2-0/

0

精彩评论

暂无评论...
验证码 换一张
取 消