Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net custom errors on specific hosts

Is there a way to display custom errors on specific host(s) (eg: www.example.com) and display vanilla errors on others (eg: beta.example.com)?

I'm thinking along the lines of configuration syntax that can be added to the customErrors section of the web.config.

It's actually for MVC 3, if that makes any difference.

The sites are hosted on separate servers. http://beta.yogaloft.co.uk/ is built and deployed automatically by appharbor and promoted to http://www.yogaloft.co.uk/ whenever it's ready for the wild.

like image 254
grenade Avatar asked May 29 '26 23:05

grenade


2 Answers

what i would do is use customized HandleErrorAttribute to detect the request and show the custom error on the www.example.com ?

basically, extend the HandleErrorAttribute ( HandleCustomErrorAttribute : HandleErrorAttribute )and put the logic to detect if the request is coming from example.com and if so show a specified view.

I have not tried it this way, but shouldnt be impossible.

like image 152
Illuminati Avatar answered Jun 01 '26 13:06

Illuminati


If this hosts are set on the same directory, you can't. All you can do - use the customErrors="RemoteOnly" setting and beta test locally. You really should use two different sites for the production and testing.

like image 34
VMAtm Avatar answered Jun 01 '26 11:06

VMAtm