iis - ASP.NET URL validation -


we have custom rest handler on asp.net configured handle incoming requests:

<add path="*" verb="*" type="rest.restprotocolhandler"/> 

however, passing pipe character, encoded or not @ all, triggers validation error seems come inside asp.net.

accessing http://localhost:8080/%7c or http://localhost:8080/| yields error:

[argumentexception: illegal characters in path.] system.io.path.checkinvalidpathchars(string path) +7489125 system.io.path.combine(string path1, string path2) +40 system.web.configuration.usermappath.getphysicalpathforpath(string path, virtualdirectorymapping mapping) +114 system.web.configuration.usermappath.getpathconfigfilename(string siteid, virtualpath path, string& directory, string& basename) +72 system.web.configuration.usermappath.mappath(string siteid, virtualpath path) +30 system.web.configuration.usermappath.mappath(string siteid, string path) +31 system.web.hosting.hostingenvironment.mappathactual(virtualpath virtualpath, boolean permitnull) +297 system.web.hosting.hostingenvironment.mappathinternal(virtualpath virtualpath, boolean permitnull) +51 system.web.cachedpathdata.getconfigpathdata(string configpath) +341 system.web.cachedpathdata.getvirtualpathdata(virtualpath virtualpath, boolean permitpathsoutsideapp) +110 system.web.httpcontext.getfilepathdata() +36 system.web.httpcontext.getconfigurationpathdata() +26 system.web.configuration.runtimeconfig.getconfig(httpcontext context) +43 system.web.configuration.customerrorssection.getsettings(httpcontext context, boolean canthrow) +41 system.web.httpresponse.reportruntimeerror(exception e, boolean canthrow, boolean localexecute) +101 system.web.httpruntime.finishrequest(httpworkerrequest wr, httpcontext context, exception e) +383

no userland code gets executed. configuration option somewhere? reproduced on iis 7 & vs studio's 2008 devel server.

stack overflow seems handle error ok, looks dynamically generated 404 mvc page gets rendered https://stackoverflow.com/%7c.

any ideas?

try intercept exception in global.asax file. implement there (global.asax.cs) method:

protected void application_error(object sender, eventargs e) {     exception ex = server.getlasterror();     //do whatever want exception     //or url context, reformat , redirect } 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -