Shivkumar
Shivkumar

Reputation: 1903

Call Controller Action through Javascript

I have call controller action through javascript using window.location

window.location = "/SomeController/SomeAction/";  

it's working fine but when i will develop it in on sub-domain it not constructing URL properly

My URL Is

http://testgecianet/pms/

when i call the action it construct URL like

http://testgecianet/SomeController/SomeAction

instead of

http://testgecianet/pms/SomeController/SomeAction 

how i can construct correct path when application deploy on SubDomain.?

Upvotes: 0

Views: 1762

Answers (1)

Yasser Shaikh
Yasser Shaikh

Reputation: 47784

did you try using @Url.Action ?

For example your code of

 window.location = "/SomeController/SomeAction/";

could be written like

window.location = "@Url.Action("SomeAction","SomeController")";

This could solve the problem, I hope.

Upvotes: 2

Related Questions