当我向我的private void chooseFile() {
try {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
try {
startActivityForResult(intent, LOAD_IMAGE_RESULTS);
} catch (ActivityNotFoundException e) {
}
} catch (Exception e) {
e.printStackTrace();
}
}
文件发送ajax请求时,我收到了错误text.aspx
但是当我将其添加到405 (Method not allowed)
时,我有web.config
401 (Unauthorized)
低于我的test.aspx.cs文件和test.aspx
<configuration>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule"/> <!-- ADD THIS -->
</modules>
</system.webServer>
</configuration>
Test.aspx文件
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Test : System.Web.UI.Page {
public string method;
public int age = 24;
protected void Page_Load(object sender, EventArgs e) {
method = Request.ServerVariables["request_method"];
if(method=="PUT") {
Response.Clear();
Response.Write("PUTEM JE");
Response.End();
}
}
}
有人可以告诉我出了什么问题吗?
答案 0 :(得分:0)
还在模块之后将此行添加到您的配置中:
<handlers>
<remove name="WebDAV" />
</handlers>
答案 1 :(得分:0)
我们可以在* .aspx路径
中的请求限制中添加PUT, DELETE
但是在我的web.config中没有它就无法工作:
<configuration>
<system.webServer>
<security>
<requestFiltering>
<verbs allowUnlisted="false">
<add verb="GET" allowed="true" />
<add verb="POST" allowed="true" />
<add verb="DELETE" allowed="true" />
<add verb="PUT" allowed="true" />
</verbs>
</requestFiltering>
</security>
<handlers>
<remove name="PageHandlerFactory-ISAPI-2.0" />
<remove name="PageHandlerFactory-Integrated-4.0" />
<remove name="PageHandlerFactory-Integrated" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" responseBufferLimit="0" />
<add name="PageHandlerFactory-Integrated" path="*.aspx" verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.UI.PageHandlerFactory" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv2.0" />
<add name="PageHandlerFactory-Integrated-4.0" path="*.aspx" verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.UI.PageHandlerFactory" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="PageHandlerFactory-ISAPI-2.0" path="*.aspx" verb="GET,HEAD,POST,DEBUG,PUT,DELETE" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="0" />
</handlers>
</system.webServer>
<system.web>
<authentication mode="None" />
</system.web>
</configuration>