View ModelState errors while debugging

Today I learned how you can view the Modelstate errors while debugging a controller in Asp.Net: ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => x.Key).ToList() Just paste that in the watch window. If you’ve tried debugging to find what field is causing the Modelstate to be invalid, you’ll know how tedious it is to dig through but thanks to this post for this handy tip!

ASP.NET max upload file size

Today I learned there are two configuration values that determine how large of a file can be uploaded. maxRequestLength is specified in Kilobytes and it’s used by the ASP.NET framework. If the file is larger than this value then the application will throw “content length exceed” exception so it just comes back as a 500 which isn’t that helpful. The default is about 4mb. maxAllowedContentLength is used by IIS and is specified in bytes not kilobytes and if the file is larger then it will return 413 error status which we can handle appropriately. The default is about 28mb. ...