1.跨域使用Ajax接口访问方式配置
查了很多的资料,有设置url重写的,有在django后端接口处做处理的,也有在前端添加请求头的,这些都尝试了无法解决,而且很麻烦,实际上很简单,只需要在web.config文件中添加一行代码配置即可解决,吐血.jpg。
说正事,一般情况下iis是不允许ajax的PUT/DELETE等接口访问方式的,想要在iis上使用ajax的PUT/DELETE接口访问方式,需要移除自身的WebDAVModule模式,因此,只需要在web.config文件中添加如下的代码即可:
<modules>
<remove name="WebDAVModule" />
</modules>
2.完整的配置代码
下面是全部的web.config
配置代码
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
<add name="Python FastCGI" path="*" verb="*" modules="FastCgiModule" scriptProcessor="D:\Program Files (x86)\Python\Python37\python.exe|E:\System_ENG\system_register\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
</handlers>
<httpRedirect enabled="false" destination="" exactDestination="false" childOnly="false" httpResponseStatus="Permanent" />
<security>
<requestFiltering allowDoubleEscaping="true">
<requestLimits maxAllowedContentLength="419430400" />
</requestFiltering>
</security>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true" />
<rewrite>
<rules>
<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^127.0.0.1:8084$" />
</conditions>
<action type="Redirect" url="http://xxxxx.xxxx.com/{R:0}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
<appSettings>
<add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
<add key="PYTHONPATH" value="E:\System_ENG\system_register" />
<add key="DJANGO_SETTINGS_MODULE" value="system_register.settings" />
</appSettings>
<system.web>
<httpRuntime executionTimeout="6000" maxRequestLength="419430400" />
<customErrors mode="Off" />
<compilation debug="true" />
</system.web>
</configuration>
ok,本文至此结束,希望对你有帮助,ths!