简体   繁体   English

mvc3网站web.config中的visual studio无法识别ssl和rewrite标记

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

I've written a simple web application using asp.net mvc3 and I have a login page which control access to the site. 我使用asp.net mvc3编写了一个简单的Web应用程序,我有一个控制访问该站点的登录页面。 Every request which is not authenticated will redirect to this page. 每个未经过身份验证的请求都将重定向到此页面。
I want to use ssl to make the site secure (using https). 我想使用ssl使网站安全(使用https)。 I don't want to use https for all of my sites because it make it heavy for browsers. 我不想对我的所有网站都使用https,因为它使浏览器变得很重。 The problem is when I add following tags to web.config, VS2010 ultimate does not recognize it and does not work. 问题是当我向web.config添加以下标签时,VS2010终极无法识别它并且无法正常工作。
I have deployed the project to IIS 7.5 too but it does not work either. 我已经将项目部署到IIS 7.5,但它也不起作用。 what should I do? 我该怎么办?

  <system.webServer>
<rewrite>
  <rule name="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. 您需要IIS的URL Rewrite扩展,并且重写标记仅适用于IIS,因此您需要将其用于您的项目。 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/ 你不需要VS验证你的xml是否正确,但如果你想要它,这里有一个指南: http//ruslany.net/2010/04/visual-studio-xml-intellisense-for-url-改写,2-0 /

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

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