I have got a webforms application I have added an MVC Area to it and within there I have a Controller called MyController.
I need to do something like the below in the master page of the web forms application. This is copied from another web app I have which is all MVC 5.
So in my Layout page on that App I have:
<script type="text/javascript">
// assign values used in core js file
returnUrl = '@Url.Action("MyAction", "My", new { returnUrl = @Request.Url.AbsoluteUri })';
anotherUrl = '@Url.Action("MyAction2", "My")';
</script>
In my core js file return url is used in a ajax call like so:
$.ajax({
url: returnUrl, // return url gets set form _Layout.cshtml
type: 'GET',
success: function (data) {
alert("yay");
},
error: function (xhr) {
alert("failed");
}
});
Is there anyway I can use the same functionality in WebForms to generate the Urls to go to MyController for these ajax urls.
I have came across this answer - is the accepted answer the correct way of doing this?