You can, because it's MVC always return a view with a specific path:
eg
return View("~/Views/myview.cshtml",model);
If that would work for you ?
But still not 100% on what you are trying to achieve, does the View need to inherit from UmbracoTemplate or similar, ie are you writing out Umbraco properties inside the view, or is it a totally seperate non Umbraco View, that you just want to have edited via the back office ?
The other option is to use RouteHijacking: (https://our.umbraco.org/documentation/reference/routing/custom-controllers)
Create a DocumentType for your request and note the alias, and create a page in Umbraco, based on that DocumentType.
Now create a controller called (naming is important)
public class DocTypeAliasController : RenderMvcController
now all requests for the page based on this DocumentType are routed through this controller via an ActionResult called Index:
public override ActionResult Index(RenderModel model)
{
// you can return your custom view here....
}
or another option would be to define a custom route:
SurfaceController views, not found in views folder
SurfaceController cannot find view in ~/Views/
Question: Why can't my SurfaceController find the View in the Views folder?
Sweet Candy:
Origin to Frustration Candy
Goal
If Else Question
Maybe there is a work around, eg
How to Make Umbraco Content > Template show views in subfolder?
Hi Anders
I might not be understanding correctly what you are aiming to do...
but normally a surface controller sits kind of on the surface of a rendermvccontroller to handle a form post
so you would likely return:
RedirectToCurrentUmbracoPage() or CurrentUmbracoPage() - keeps the modelstate intact
or one of the other helpers, once you have done something with the posted data.
Alternatively you can create a child action on a surfacecontoller and render it's output within a template using
@Html.Action("actionname","controllername")
in this case your child action would return a partial view and you would create this in the /views/partials folder
and then you could edit the html of the partial view via the back office in the settings/partial views tree
regards
marc
Hi Marc - High Five
Thank you for replying back!
So let me rephrase my situation.
1. *Isn't it a fail in the Umbraco documentation that it says that the VIew can be in the ~/Views/?
Source + Quote:
Routing for locally declared controllers
2. I want to call a http request (Call a URL) and receive a View that can be seen in Umbraco.
/Anders
Hi Anders
(yes the documentation may be out of date)
You can, because it's MVC always return a view with a specific path:
eg
If that would work for you ?
But still not 100% on what you are trying to achieve, does the View need to inherit from UmbracoTemplate or similar, ie are you writing out Umbraco properties inside the view, or is it a totally seperate non Umbraco View, that you just want to have edited via the back office ?
The other option is to use RouteHijacking: (https://our.umbraco.org/documentation/reference/routing/custom-controllers)
Create a DocumentType for your request and note the alias, and create a page in Umbraco, based on that DocumentType.
Now create a controller called (naming is important)
now all requests for the page based on this DocumentType are routed through this controller via an ActionResult called Index:
or another option would be to define a custom route:
https://our.umbraco.org/documentation/reference/routing/custom-routes
http://shazwazza.com/post/custom-mvc-routes-within-the-umbraco-pipeline/
regards
Marc
is working on a reply...