Pass in Active Directory user name (DOMAIN\\etc) i

2019-09-05 00:35发布

问题:

I'm trying to pass an active directory user name in to a asp.net MVC application, but can't figure out what's the best way to deal with the backslash in the user name.

For example, say my user name is "EUROPE\george.collins" and I want my record for 2012:

http://application/2012/EUROPE\George.Collins

If I URL-encode the backslash as %5C the server is returning a "400 Bad Request".

Should I just separate the DOMAIN and User Name parts, e.g. 2012/EUROPE/George.Collins?

In that case, what would be the easiest way to re-combine them into a username string?

G

回答1:

I think I've found my answer here: How to URL encode parameters in ASP .NET MVC

It looks like I have to leave the user id parameter out of the route pattern, so that it will be appended as a querystring ?userid=... where the URL encoding is valid.