简体   繁体   中英

Dots and "/" in URL causing 404 (Not Found)

Hello Stackoverflow community, I'm getting a 404 (Not Found) message when making this call from my typescript code:

http://localhost:9090/api/employees/ERNEST A/L I.G. MILLER,/1/1/1/1/1

But when I make this call it does work.

http://localhost:9090/api/employees/ERNEST MILLER,/1/1/1/1/1

I tried using the encodeURIComponent to encode my call but that doesnt encode DOTS and giving me same 404 error.

 http://localhost:9090/api/employees/ERNEST%20A%2FL%20I.G.%20MILLER,/1/1/1/1/1

I then tried adding trailing "/" at the end of my call but that didnt work either.

http://localhost:9090/api/employees/ERNEST%20A%2FL%20I.G.%20MILLER,/1/1/1/1/1/

I even tried other solutions on stackoverflow but none of them worked for me.

Solutions I tried but not worked.

<system.webserver>
<modules runAllManagedModulesForAllRequests="true">


<system.web>
<httpRuntime relaxedUrlToFileSystemMapping="true" />

<add name="ApiURIs-ISAPI-Integrated-4.0"
path="/people/*"
verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS"
type="System.Web.Handlers.TransferRequestHandler"
preCondition="integratedMode,runtimeVersionv4.0" />

I am using ASP .Net, MVC 5.2.4.0 and Angular 6 for my project. Any help would highly be appreciated.

尝试将此添加到您的 web.config

<modules runAllManagedModulesForAllRequests="true" />

Adding dots and '/' is not recommended way in configuring the routers. Instead of putting the original value including those special letters, you can easily encode and decode them.

So encode the value to Base64 string and put it on url, and on that url, decode it and use that value.

In normal, it is fine to put the key or guid into the routes (but should avoid the special characters), but in your case, it will be good to encode that string and use by decoding.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM