Reputation: 1
Is there any way to make my asp.net mvc5 applications runtime compilation like angular. In traditional way I change in .cshtml file save and press f5 to refresh running page then I get my change effect on page. But is there any way that can reload my page without pressing f5 in browser as like as angular application do.
Upvotes: -3
Views: 156
Reputation: 772
Ajax refreshes the current page and gets the data from the server.
As shown in the code: ajax calls the Test action method under the PageLoad controller.
The background code is as follows:
public ActionResult Test()
{
var actionResult = default(JsonResult);
var stu = new STU();
this.UpdateModel(stu);
var tmp = string.Format("{0}{1} old from {2}", stu.Name, stu.Age, stu.City);
actionResult = new JsonResult()
{
Data = new { Message = tmp }
};
Thread.Sleep(5000);
return actionResult;
}
According to the student information passed by the front desk, return a string to ajax.
<form id="student_form">
<input type="submit" id="sub" value="submit" />
</form>
$(document).ready(function() {
$('#student_form').submit(function() {
$.ajax({
// ajax submit code....
});
return false;
});
});
Upvotes: 0