c# - make controller actions' "return partialview()" automatically link to a "_partialview.cshtml" in asp.net mvc3 -


I am writing a page in MVC3, and there are some places where I want to request a page in Ajax and URL bar too

If the request is a complete page then I have to give the action "example.cshtml" which is a complete view. But this request is an Ajax request, I would like to present only "_Example.cshtml" which is a partial view.

My code is

  if (request IsAjaxRequest ()) {return partial view ("_example"); } See Return ();   

But since the MVC3 is about all conventions and it's all reconfigurable, I want to be able to write

  (Request.IsAjaxRequest ( )) {Return partial view (); } See Return ();   

and still load "_Example.cshtml" if it is a partial view. I do not even clear all my partial thoughts by the name "_Something.cshtml" if I can only call partial views (); ?

Please tell me that this is possible. And tell me how.

Edit:

I still want to be able to separate partial footage from ideas, so changing the masterpage will suffice for just a few cases.

I want to do something like overload the default path to see partial views like:

  partial view space = new [] {"~ / views / {1} / _ {0} .ascx ",};   

But it also affects the partial view ("Example") to use _Example.cshtml, which is undesirable.

Edit:

One other thing I have tried is to fill the controller partial view () and partial visual (object model) methods with overload, but they do not override I can not go and I can find a suitable way to find out what action they were called from.

Have you seen? It can help you in what you are looking for.

Comments