Not sure why it is looking in to umbraco/Surface/.
Also In my controller I get action to add data in to database , after insertion I would like to redirect the user to Index action using :
return RedirectToAction("Index");
But I am having same issue getting error "The resource cannot be found".
The controller code :
public class BrandController : SurfaceController
{
public readonly MongoProductRepoContext MongoContext = new MongoProductRepoContext();
// GET: Brand
public ActionResult Index()
{
return PartialView("BrandFormView", new PostBrand());
}
[HttpPost]
public ActionResult addNewBrand(PostBrand pBrand)
{
var brand = new SGBrand(pBrand);
MongoContext.Brands.InsertOne(brand);
return RedirectToAction("Index");
}
Redirect and HtmlAction
Hi, I have a small form to add Brands in to database. I have created a partial view for form. The form has HtmlAction :
But When I click the link I get error message :
The resource can not be found
The URL changes to : http://localhost:53298/umbraco/Surface/Brand
Not sure why it is looking in to umbraco/Surface/.
Also In my controller I get action to add data in to database , after insertion I would like to redirect the user to Index action using :
But I am having same issue getting error "The resource cannot be found".
The controller code :
Any idea?
Thanks
Any help please. Thanks
Please could you try:
return RedirectToAction("/Index"); //add slash before Index
Reference: https://stackoverflow.com/a/42869656/4489400
Hope this helps.
/umbraco/Surface is the route that the surfacecontrollers are accessed from.
Not tried a redirect to action, try a RedirectToCurrentUmbracoPage()
Hi Huw,
The problem happens when I create a new item on /CreateNew page and need to redirect to Index page.
I tried to
return RedirectToAction("Index");
but didn't work, tried adding slash before Index and it worked.The reference on the link above explains the reason why. Hope it works out for you.
Thanks, A
What is the url that would normally get them to the index page? could you not to a simple redirect to that Redirect("umracopageurl") ?
you could try
RedirectToAction("Index","Brand",null) it is one of the overrides, that may work
is working on a reply...