相关疑难解决方法(0)

Post参数始终为null

自从升级到RC for WebAPI后,我在WebAPI上调用POST时遇到了一些奇怪的问题.我甚至回到了新项目生成的基本版本.所以:

public void Post(string value)
{
}
Run Code Online (Sandbox Code Playgroud)

并从Fiddler打来电话:

Header:
User-Agent: Fiddler
Host: localhost:60725
Content-Type: application/json
Content-Length: 29

Body:
{
    "value": "test"
}
Run Code Online (Sandbox Code Playgroud)

当我调试时,字符串"value"永远不会被分配给.它总是为NULL.谁有这个问题?

(我第一次看到更复杂类型的问题)

问题不仅仅是绑定到ASP.NET MVC 4,在安装RC后,新的ASP.NET MVC 3项目也会出现同样的问题

.net c# asp.net-web-api asp.net-web-api-routing

195
推荐指数
11
解决办法
31万
查看次数

哪个获得优先权,maxRequestLength或maxAllowedContentLength?

在更改上传允许的最大文件大小时,我偶然发现了这两个设置.

sytem.web中,您拥有带有maxRequestLengthhttp运行时节点.在system.webServer中,您拥有带有maxAllowedContentLengthrequestLimits.

现在哪个优先于另一个?我们需要设置两个或者是最后一个(IIS7的那个)足够吗?

asp.net file-upload web-config maxrequestlength

124
推荐指数
2
解决办法
5万
查看次数

如何在IIS7上运行时将maxAllowedContentLength设置为500MB?

我将maxAllowedContentLength更改为

<security>
    <requestFiltering>
        <requestLimits maxAllowedContentLength="5024000000" />
    </requestFiltering>
</security>
Run Code Online (Sandbox Code Playgroud)

在我的web.config中,但在IIS7上运行时出现此错误:

'maxAllowedContentLength'属性无效.不是有效的无符号整数

http://i.stack.imgur.com/u1ZFe.jpg

但是当我在VS服务器中运行时,它正常运行而没有任何错误.

如何配置我的网站允许上传500MB大小的文件,在IIS7上没有这个问题?

asp.net iis-7 file-upload .net-4.0

84
推荐指数
3
解决办法
15万
查看次数

IIS7 - 请求筛选模块配置为拒绝超过请求内容长度的请求

我想上传图片,它在我的机器上工作正常,但当我把我的网站放在IIS7服务器上公开时,我无法上传任何内容.

错误

请求过滤模块被配置为拒绝超过请求内容长度的请求.

最可能的原因

在Web服务器上配置请求筛选以拒绝请求,因为内容长度超过了配置的值.

你可以尝试的事情

验证applicationhost.config或web.config文件中的configuration/system.webServer/security/requestFiltering/requestLimits@maxAllowedContentLength设置.

Web.config中的system.webServer

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
    <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1048576" />
      </requestFiltering>
   </security>
  </system.webServer>
Run Code Online (Sandbox Code Playgroud)

如您所见,我将maxAllowedContentLength设置为1gb.重新启动我的网站仍然收到此错误.我/uploads/在我的文件系统上创建了一个文件夹,它也是如此.不知道导致此错误的原因以及无法上传图片的原因.

asp.net iis iis-7 asp.net-mvc-3

59
推荐指数
1
解决办法
10万
查看次数

在ASP.NET MVC中文件上载超过允许的大小时显示自定义错误页面

我的主要问题是,当上传的文件超出允许的大小时,我想显示自定义错误页面(web.config中的maxRequestLength).

上传大文件时,在调用控制器中的上传操作方法之前会抛出HttpException.这是预料之中的.

我试图在自定义属性中捕获异常,并在控制器中覆盖OnException.为什么不能在属性或OnException方法中捕获异常?

虽然可以在global.asax中捕获Application_Error中的异常,但Response.Redirect和Server.Transfer都不能用于重定向到自定义错误页面.Server.Transfer给出"未能处理子请求"错误,而response.redirect给出"已发送Http头"错误.

有任何想法吗?

提前致谢!

马库斯

c# asp.net asp.net-mvc iis-7 iis-6

41
推荐指数
1
解决办法
3万
查看次数

Sys.WebForms.PageRequestManagerServerErrorException:在服务器上处理请求时发生未知错误."

我在页面上有几个更新面板和jquery选项卡.而且我还在更新面板上加载几个用户控件.用户等待几分钟后(未检查时间约40分钟).当用户从提交按钮发送请求时,它给出了以下错误?

'Sys.WebForms.PageRequestManagerServerErrorException:
Sys.WebForms.PageRequestManagerServerErrorException: An unknown 
error occurred while processing the request on the server. The status 
code returned from the server was: 0' when calling method: 
[nsIDOMEventListener::handleEvent]
Run Code Online (Sandbox Code Playgroud)

我无法追踪此问题以解决问题.但我相信.这是由Ajax引起的.大师,如果你知道解决方案.请告诉我.

javascript c# asp.net ajax jquery

34
推荐指数
6
解决办法
17万
查看次数

如何解决"超出最大请求长度"异常?

当我上传图片时出现此错误:

超出最大请求长度

我该如何解决这个问题?

asp.net

27
推荐指数
3
解决办法
7万
查看次数

最大请求长度超出异常

我正在尝试使用上传控件上传一个20兆的文件,它在visual studio的内置web服务器上工作正常,但是一旦我将它发布到生产服务器(我无法访问),我就会收到以下错误:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Maximum request length exceeded. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: Maximum request length exceeded.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception …
Run Code Online (Sandbox Code Playgroud)

exception asp.net-2.0

19
推荐指数
1
解决办法
3万
查看次数

System.Web.HttpException(0x80004005):超出最大请求长度

我试图在ASP.NET MVC 5应用程序中上传大小为5.25 MB的mp4视频文件.

我已经尝试将此添加到Web.config文件中,在大多数情况下,该文件已被接受为此问题.

<system.web>
    <!-- This will handle requests up to 1024MB (1GB) -->
    <httpRuntime maxRequestLength="1048576" />
</system.web>
Run Code Online (Sandbox Code Playgroud)

我也尝试在Web.config中设置超时

<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
Run Code Online (Sandbox Code Playgroud)

但是,当我上传文件时,我得到了 System.Web.HttpException (0x80004005): Maximum request length exceeded.

也许有些东西需要在控制器或视图中设置?

控制器:

[HttpPost]
public ActionResult Index(HttpPostedFileBase file)
{
    if (file != null && file.ContentLength > 0)
    {
        var fileName = Path.GetFileName(file.FileName);
        if (fileName != null)
        {
            var path = Path.Combine(Server.MapPath("~/Content/Videos"), fileName);
            file.SaveAs(path);
        }
    }
    return RedirectToAction("Index");
}
Run Code Online (Sandbox Code Playgroud)

视图:

@using (Html.BeginForm("Edit", "Posts", FormMethod.Post, new { enctype =  "multipart/form-data" })) …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc

14
推荐指数
1
解决办法
2万
查看次数

使用HttpWebRequest向servicestack服务发送大型(8mb)excel文件时出错

我正在尝试将大型excel文件发送到其余服务(使用servicestack).

客户端和服务器(Servicestack服务)应用程序部署在不同的服务器上.

我在客户端使用以下代码上传excel文件(8 MB大小)

取自

http://www.codeproject.com/Articles/501608/Sending-Stream-to-ServiceStack

 HttpWebRequest client = (HttpWebRequest)WebRequest
                 .Create(ConfigurationManager
                 .AppSettings["applicationUrl"] 
                   + @"/servicename/" 
                   + fileUpload.FileName 
                   + @"/" + FileType + @"/" 
                   + Utility.UserName + @"/" 
                   + Utility.EmployerID + @"/" 
                   + UploadedFrom);

 client.Method = WebRequestMethods.Http.Post;  

 ////the following 4 rows enable streaming 
  client.AllowWriteStreamBuffering = false;
  client.SendChunked = true;
  client.ContentType = "multipart/form-data;";
  client.Timeout = int.MaxValue;
   // client.KeepAlive = false;
  //client.ProtocolVersion = HttpVersion.Version10;
 //client.ContentLength = 0;
 //client.Timeout = Timeout.Infinite;
//client.AllowWriteStreamBuffering = true;
Stream stream = fileUpload.InputStream;

if (stream.CanRead)  
{  stream.Copy(client.GetRequestStream());
}

   var response …
Run Code Online (Sandbox Code Playgroud)

c# asp.net rest servicestack

6
推荐指数
1
解决办法
652
查看次数