hi, i have a clean test Umbraco 8 website.
i am trying to create page and SurfaceController but nothing happened.
in other site (umbraco 7) it usualy work.
my code:
Controller:
public class TestRedirectController : SurfaceController
{
// GET: TestRedirect
[HttpPost]
public ActionResult Index()
{
return View();
}
}
The first thing that stands out is you are calling a Post method via Http.Action which I don't believe is possible. Try taking the [HttpPost] attribute off of your action on your controller and see if that works.
Ok, so it looks like this isn't a problem with your surface controller now, I'd say it's an issue with your source url.
Because of how you've got things set up, it appears to me that you are trying to go to an existing page in the site, then when it comes to render the view for that page, hit your surface controller.
That error tells me that either the page you are trying to go to initially doesn't exist or it has no template set against it.
Things to check:
Does a page called TestRedirect exist in your Umbraco back office, and is it's url /testredirect?
That's fine from a template point of view, but you need a doc type and a page to exist in your content tree. It's not possible to route "just" to a view which I think is what you are currently trying to do.
What is your overall objective with this controller/Action?
Umbraco 8 SurfaceController not working
hi, i have a clean test Umbraco 8 website. i am trying to create page and SurfaceController but nothing happened. in other site (umbraco 7) it usualy work. my code: Controller:
Template:
@{ Layout = "master.cshtml"; }
@Html.Action("Index", "TestRedirect")
View:
@{ Layout = null; }
Hi Iiran,
The first thing that stands out is you are calling a Post method via Http.Action which I don't believe is possible. Try taking the
[HttpPost]
attribute off of your action on your controller and see if that works.Thanks
Nik
still not working
Hi Iiran,
What is the exact error you are getting?
Thanks
Nik
just 404, it doesn't even enter the controller.
update: when i use the full link it workes: http://localhost:59216/umbraco/surface/testredirect/Index/
but it doesn't work with template.
Ok, so it looks like this isn't a problem with your surface controller now, I'd say it's an issue with your source url.
Because of how you've got things set up, it appears to me that you are trying to go to an existing page in the site, then when it comes to render the view for that page, hit your surface controller.
That error tells me that either the page you are trying to go to initially doesn't exist or it has no template set against it.
Things to check:
hi Nik, i wanted to thank you for you help.
this is what i usualy do...
Hi Iiran,
That's fine from a template point of view, but you need a doc type and a page to exist in your content tree. It's not possible to route "just" to a view which I think is what you are currently trying to do.
What is your overall objective with this controller/Action?
hi, i'm doing some testing with umbraco forms. i just wanted to test receiving FormID after form has submited to another controller.
i got it to work, i needed the docType and create a page. thank you very much for your help.
No worries :-) Happy it's working for you.
is working on a reply...