httpexception

ASP.Net debug directory monitoring HttpException

我的梦境 提交于 2019-11-27 04:50:54
问题 When I start my ASP.Net 4.0 web app in debug mode, I'm getting the following exception: System.Web.HttpException occurred Message=Invalid file name for file monitoring: 'C:\src\main-232\src\ZNode\Znode_MultiFront\Web\Controls\Cat5\Navigation'. Common reasons for failure include: - The filename is not a valid Win32 file name. - The filename is not an absolute path. - The filename contains wildcard characters. - The file specified is a directory. - Access denied. Source=System.Web ErrorCode=

HttpContext throws HttpException

≡放荡痞女 提交于 2019-11-26 20:35:41
问题 I have written a custom http handler. I have done this by writing a class which implements the IHttphandler. Inside that class I have code like this, context.Response.Clear(); context.Response.ClearHeaders(); context.Response.AddHeader("Content-Disposition", "attachment;filename=" + attachmentFileName); context.Response.AddHeader("Content-Length", new FileInfo(downloadFile).Length.ToString()); context.Response.ContentType = GetMimeType(attachmentFileName); context.Response.TransmitFile

ASP.NET Core equivalent of ASP.NET MVC 5's HttpException

旧时模样 提交于 2019-11-26 15:37:28
问题 In ASP.NET MVC 5 you could throw a HttpException with a HTTP code and this would set the response like so: throw new HttpException((int)HttpStatusCode.BadRequest, "Bad Request."); HttpException does not exist in ASP.NET Core. What is the equivalent code? 回答1: I implemented my own HttpException and supporting middleware which catches all HttpException 's and turns them into the corresponding error response. A short extract can be seen below. You can also use the Boxed.AspNetCore Nuget package.

Why do I get “Cannot redirect after HTTP headers have been sent” when I call Response.Redirect()?

ぃ、小莉子 提交于 2019-11-26 12:15:01
When I call Response.Redirect(someUrl) I get an HttpException: "Cannot redirect after HTTP headers have been sent". Why do I get this? And how can I fix this issue? According to the MSDN documentation for Response.Redirect(string url) , it will throw an HttpException when "a redirection is attempted after the HTTP headers have been sent". Since Response.Redirect(string url) uses the Http "Location" response header ( http://en.wikipedia.org/wiki/HTTP_headers#Responses ), calling it will cause the headers to be sent to the client. This means that if you call it a second time, or if you call it

Catching “Maximum request length exceeded”

萝らか妹 提交于 2019-11-26 10:14:40
I'm writing an upload function, and have problems catching "System.Web.HttpException: Maximum request length exceeded" with files larger than the specified max size in httpRuntime in web.config (max size set to 5120). I'm using a simple <input> for the file. The problem is that the exception is thrown before the upload button's click-event, and the exception happens before my code is run. So how do I catch and handle the exception? EDIT: The exception is thrown instantly, so I'm pretty sure it's not a timeout issue due to slow connections. Damien McGivern There is no easy way to catch such

Why do I get “Cannot redirect after HTTP headers have been sent” when I call Response.Redirect()?

倾然丶 夕夏残阳落幕 提交于 2019-11-26 02:55:15
问题 When I call Response.Redirect(someUrl) I get the following HttpException: Cannot redirect after HTTP headers have been sent. Why do I get this? And how can I fix this issue? 回答1: According to the MSDN documentation for Response.Redirect(string url) , it will throw an HttpException when "a redirection is attempted after the HTTP headers have been sent". Since Response.Redirect(string url) uses the Http "Location" response header (http://en.wikipedia.org/wiki/HTTP_headers#Responses), calling it