Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Sunday, June 29, 2014 4:31 AM
Hi
I used a handler in a project in VS2012 to send images to client and It worked. Now I uses it in VS2013 with some modifications but there is the error in the subject. Can anyone help? The error page follows:
Server Error in '/' Application.
Server cannot set status after HTTP headers have been sent.
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: Server cannot set status after HTTP headers have been sent.
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 stack trace below. |
Stack Trace:
|
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18447
All replies (9)
Monday, June 30, 2014 10:05 PM
Hi,
For this situation, about the error, "Server cannot set status after HTTP headers have been sent.", you could refer to the following information:
Regards
Tuesday, July 1, 2014 1:35 AM
Hi
I searched for this error and tested many cases that caused this error but there was no change. When I started the next day It worked. I changed all of changes to previous state but it still worked!!! This makes me happy and at the same time frightened. I work with Web Forms. Thank you anyway.
Regards
Saturday, July 19, 2014 11:02 AM
Hi
I found the reason behind this error. I my handler I send the following HTTP codes based on the situation:
400, Bad Request
401, Unauthorized
403, Forbidden
404, Not Found
304, Not Modified
200, OK
All of them produces the expected result except 401, Unauthorized. When I set the StatusCode and StatusDescription to these values, there is this server error. I guess it interfere with ASP.NET authorization. Now there is the following question:
1-What is the real reason?
2-Can 401 code can be used in handlers?
Thanks
Friday, August 22, 2014 3:03 PM
I'm also looking for a solution to this. I'm using an Authorization filter to lock down specific controllers and it looks like Owin for some reason is conflicting with this. When authorization fails and I set the status code to 401, I get this error. THis just started happening after upgading to Microsoft.AspNet.Identity.Owin version="2.1.0
Any ideas?
Friday, August 22, 2014 3:09 PM
I also submitted issue here...
https://katanaproject.codeplex.com/workitem/341
Friday, August 22, 2014 3:59 PM
app.UseCookieAuthentication(New CookieAuthenticationOptions() With
{
.AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie
})
' removing this line from the above code fixed the issue. I don't need owin to redirect when i get a 401.
',.LoginPath = New PathString("/Connector/PopUp")
Wednesday, February 8, 2017 9:03 AM
Hi,
i am also getting the same issue but this issue is coming in live website only.on my local server i am not finding any issue.can any body help me what are the preferred reasons of this issue and how can i solve this.
i am using mvc 3 with orchard solution.
Tuesday, May 2, 2017 7:24 AM
try to use RedirectResult() method to redirect to a url instead of Response.Redirect() .like below example.
string url = HttpContext.Request.Url.AbsoluteUri.Replace(HttpContext.Request.Url.AbsolutePath, "/Index.aspx");
filterContext.Result = new RedirectResult(url);
above Index.aspx you can change whatever you want to redirect page.
Monday, January 28, 2019 5:45 PM
Thanks. This did the magic instead of a Respose.Redirect:
public ActionResult SearchResult()
{
return new RedirectResult(Request["selection"].ToString());
}