I'm currently developing a website using Angular 1 with an ASP.NET MVC backend. I'm trying to create a link that will gather certain parameters using JavaScript, retrieve the correct URL from a controller, and then redirect the user to a different website. Unfortunately, none of my attempts seem to be successful.
Here is the relevant HTML code:
<a href="#" target="_blank" id="Link">Some text</a>
This is the JavaScript function I have implemented:
$("#Link").on('click', function (event) {
event.preventDefault();
window.location = "/Data/SendToOtherSite?Name=" + $("#nameTextBox").val() + "&Email=" + $("#emailTextBox").val();
});
And here is the method in my controller:
public ActionResult SendToOtherSite(string Name, string Email)
{
string url = System.Web.Configuration.WebConfigurationManager.AppSettings["OtherSiteUrl"]
+ "/Data/DataFromOldSite?name=" + Name + "&email=" + Email;
return Redirect(url);
}
Even though I have set a breakpoint on the SendToOtherSite() method, it is never triggered, and the user is not redirected to the new website. What am I missing or doing wrong?