Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
634 views
in Technique[技术] by (71.8m points)

asp.net - Response.TrySkipIisCustomErrors not working

I have a page where i want the page to return a 404 response but remain on that page. Please don't ask why - the client wants it that way even after i discussed it with him.

I've got a .net page written in C# running under iis 8 and the app pool is configured to run under 4.0 integrated mode

When i set the statuscode to 404 in the page, it gets sent to the custom 404 error page that's set up for this site. After googling i found another post on SO mention using Response.TrySkipIisCustomErrors. From what i read it sounds like it's exactly what i need. I tried setting it to true and it had no effect in the behavior of the page - still get sent to the customer 404 error page that's setup in iis.

Anyone have any ideas why this isn't working?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Well - this is a first. First time I managed to find the answer before hitting the submit button :)

Found this IIS.net article: http://www.iis.net/configreference/system.webserver/httperrors which then lead me to find this: http://msdn.microsoft.com/en-us/library/ms690576(v=vs.90).aspx

Scroll down to the part that explains what the options for existingResponse mean. I had mine set to Replace which means it ignores TrySkipIisCustomErrors completely. Changed it to Auto and it's working.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...