How to create and go to MVC endpoint with Javascript

Hi:

I have an MVC app in which I am doing a lookup in javascript and would like the program to take me to the following endpoint:

http://localhost:44328/Admin/ManageUsers/UserDetails/?username=jsmith

Open in new window


I have a have a javascript function that looks like this:

 window.SalesHub.SearchBox_Select = function(e) {
        var baseUrl = 'http://localhost:44328';
        var actionUrl = '/Admin/ManageUsers/UserDetails/\?username=';
        var userName = 'jsmith';
        window.location.pathname = baseUrl + actionUrl + userName ;
}

Open in new window


My problem is that this function takes me to:
http://localhost:44328/Admin/ManageUsers/UserDetails/%3Fusername=jsmith

Open in new window


and tells me that "A potentially dangerous Request.Path value was detected from the client"

I have tried escaping the '?' character but that does not seem to work.  Any assistance on how to make this function take me to the endpoint that I want to go to greatly appreciated..

RBS
RBSAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Najam UddinCommented:
try this
window.location.pathname= '@Url.Action("UserDetails", "ManageUsers", new{ area = "Admin", username ="jsmith"})'

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
louisfrCommented:
Set the href property instead.
The pathname starts after the hostname and port and ends before the querystring. It cannot contain a question mark. That's why it is escaped.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.