0

I am using Ajax.BeginForm to submit data etc, but when I look at Request.Url etc I get the URL of the Ajax request. Is there a way I can get URL of the actual page the user is on?

Basically, I need to obtain id (routevalue) from the URL without passing anything to the Ajax-actionlink.

2 Answers 2

1

Why not directly pass the information you need in the request:

<%: Ajax.ActionLink(
   "Some link text", 
   "ActionName", 
   // Notice how the id value is extracted from the route
   // and used to construct the link
   new { id = RouteData.Values["id"] },
   new AjaxOptions { OnSuccess = "success" }
) %>
Sign up to request clarification or add additional context in comments.

1 Comment

because RouteData.Values get messed up if there's an Ajax request that is updating the div that contains the ActionLink that you just posted.
0

You could try using the UrlReferrer property of the HttpRequest class. I'm not sure if it will work on every case of your application, but you could give it a try.

1 Comment

it won't work. If there hasnt been any Ajax calls, URLreferrer will point to incorrect stuff

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.