Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将规则重写为js和png文件的web.config_C#_Asp.net Web Api - Fatal编程技术网

C# 将规则重写为js和png文件的web.config

C# 将规则重写为js和png文件的web.config,c#,asp.net-web-api,C#,Asp.net Web Api,我有一个应用程序ASP.Net,带有c的Web api,它使用https,我希望js、css文件和图像通过http发送。 我尝试了不同的想法,但没有成功。 我试过这个: <rewrite> <rules> <rule name="Redirect Image to HTTP"> <match url=".*\.(gif|jpg|jpeg|png|css|js)$"/> <action type="Red

我有一个应用程序ASP.Net,带有c的Web api,它使用https,我希望js、css文件和图像通过http发送。 我尝试了不同的想法,但没有成功。 我试过这个:

<rewrite>
  <rules>
    <rule name="Redirect Image to HTTP">
      <match url=".*\.(gif|jpg|jpeg|png|css|js)$"/>  
      <action type="Redirect" url="http://{SERVER_NAME}/{R:1}" redirectType="SeeOther"/>

  </rules>
</rewrite>
我做错了什么?

试试这个

<rules>
    <rule name="Redirect Image to HTTP">
      <match url=".*\.(gif|jpg|jpeg|png|css|js)$"/>  
      <action type="Redirect" url="http://{SERVER_NAME}/{R:1}" redirectType="Found"/>

  </rules>

可能您应该指定HTTPS作为条件:

<rewrite>
  <rules>
    <rule name="Redirect Image to HTTP">
      <match url=".*\.(gif|jpg|jpeg|png|css|js)$"/>  
      <conditions>
           <add input="{HTTPS}" pattern="ON" />
      </conditions>
      <action type="Redirect" url="http://{SERVER_NAME}/{R:1}" redirectType="SeeOther"/>
  </rules>
</rewrite>

顺便说一句,在regexp中使用.+比使用.*更好。

也许它可以工作,但页面仍在加载。。加载。。加载。。大约3分钟。。。我尝试使用http发送的图像未加载到页面中。是否尝试通过直接链接加载图像?结果如何?我已经尝试过了,如果图像是http或https,页面不会停止加载。。。图像正在加载中。。我该怎么办?怎么了?所有这些都在本地计算机上。。尚未在服务器上。两个建议:1。您在http和https或2之间有无限重定向。未正确配置https。没有这条规则一切都正常吗?是的。。没有规则,项目工作很好。。。如何检查无限重定向?有什么建议吗?非常感谢同样的事情:页面仍在加载,但我试图通过http发送的文件不存在。。