John Baird John Baird - 1 year ago 133
ASP.NET (C#) Question

Webapi 2 Attribute Routing

I have the following routes set up in a user controller:

[EnableCors("*", "*", "*")]
public class UserController : ApiController
public IHttpActionResult Get()

public IHttpActionResult Get(int id)

public IHttpActionResult ValidateUser()

public void VerifyUserEmailAddress(string identityId, string emailAddress)

The first three routes work just fine. But the fourth fails with a 404. I'm using fiddler to make the call:

http://localhost:39897/api/users/verify/asldkfj/ (post is selected)

Does post require data sent in the body? Can anyone see what I'm doing wrong and why the verify route is not being found?

Answer Source

The .com in the email is the issue.

Sure its a valid email, but IIS treats requests with file extensions as actual file requests and tries to find it on disk. When it can't find it then you get the 404 Not Found

If you add a trailing slash / to the request it should work.

ie http://localhost:39897/api/users/verify/asldkfj/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download