Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refresh a page in MVC

Tags:

How to refresh the current page in MVC.

[HttpGet]
public ActionResult Request()
{
    if (Session["type"] != null  && Session["resulttype"] != null)
    {
        return View();
    }
    else
    {
        return null;
    }
}

I want to refresh my page in else part. That is when return null value.

like image 259
Jinesh Avatar asked Mar 19 '14 05:03

Jinesh


People also ask

How to refresh page in MVC?

Just Redirect to the Action you want to redirect to. It will refresh your page. @Indianprogrammer According to Object Oriented Programming concept=> If you will return the 'RedirectToAction' then your method execution completes. else 'RedirectToAction' will be used as a Method for Processing something.

How do you refresh a page in HTML?

Window location.reload() The reload() method reloads the current document. The reload() method does the same as the reload button in your browser.

How do I refresh the page in asp net?

Write("<script type='text/javascript'> setTimeout('location. reload(true); ', timeout);</script>"); Put the above code in button click event or anywhere you want to force page refresh.


1 Answers

You can use Request.UrlReferrer.ToString()

[HttpGet]
public ActionResult Request()
{

    if (Session["type"] != null  && Session["resulttype"] != null)
        return View();
    else
        return Redirect(Request.UrlReferrer.ToString());
}
like image 96
Jeyhun Rahimov Avatar answered Nov 12 '22 10:11

Jeyhun Rahimov