Jeffrey
Jeffrey

Reputation: 313

Call ajax when MVC project starts

When I start my MVC application I want to call:

$.ajax({
   url: "@Url.Action("CreateInstance", "Home")",
   type: "POST"
});

This works! But I want to call it only once. If I switch from page to page this function is still getting called. I only want to call the function if I start the project. Is this possible?

Upvotes: 0

Views: 62

Answers (1)

Will
Will

Reputation: 377

You probably want to call the code directly in your global.asax . If you aren't outputting any data to the page, why use ajax?

Upvotes: 2

Related Questions