Hi I'm having a curious problem
I have a Controller called "CallbackController" it inherits : RenderMvcController and has no View as all it does is redirect to a another action on the same controller.
I Use RedirectToChildAction, but when I do the I get thi YSOD "No route in the route table matches the supplied values." error, I definitely doing something wrong, but I cant figure out what.
public class SignInCallbackController : RenderMvcController
{
private readonly IManageAuthentication _authentication;
public SignInCallbackController(IManageAuthentication authentication)
{
_authentication = authentication;
}
// GET: MemberLogin
public async Task<ActionResult> Index()
{
var code = Request["code"];
var state = Request["state"];
var error = Request["error"] ?? string.Empty;
var response = await _authentication.GetResponse(code, state, error);
return RedirectToAction("LoggedIn", "SignInCallback");
}
[ChildActionOnly]
[Authorize]
public ActionResult LoggedIn(RenderModel model)
{
return View();
}
}
Async methods with an RenderMVCController have not been a happy couple.
General approach would be not to call the Index() action at all and make your actions async by targeting the template’s action which take precedence over the default Index action.
To do this without a document might make it even harder.
Still, the following links provide information and explain several workarounds.
In that case, it looks like the ChildActionOnly or Authorize attribute is preventing you from accessing it.
In order to check if the routing itself is working correctly, could you temporarily remove the ChildActionOnly attribute in order to see if your LoggedIn action will be called.
If that doesn't work, try also removing the Authorize attribute.
(I know ... it's ugly but it's only temporarily)
In case it is being called succesfully, the next step will be to find out how the attributes can be used successfully or search for a workaround for that.
Further, you say that Index has a document.
Do you mean by that, that you have a document type (named SignInCallback) that does have a template? If it has a template, what's the name of that template?
If it's named LoggedIn, I would expect the LoggedIn action of the controller to be accessible via default Umbraco routing.
I Ended up using a node anyways, but i'm not really liking that i have to create documents for somethin in umbraco that the user is not supposed to see
It does indeed not feel right to have to create a document if that document has no use at all.
What I do not understand yet is what you would like the LoggedIn method to return.
If I understand you correctly it returns something that you do not want to be managed by Umbraco. (Otherwise, if that content would be managed within the Umbraco pipeline, a node would make sense ... right?)
Still, it would surprise me if it cannot be solved in a more sensible way.
Redirect to Action from within controller
Hi I'm having a curious problem I have a Controller called "CallbackController" it inherits : RenderMvcController and has no View as all it does is redirect to a another action on the same controller.
I Use RedirectToChildAction, but when I do the I get thi YSOD "
No route in the route table matches the supplied values."
error, I definitely doing something wrong, but I cant figure out what.Any thoughts?
I Would really like to do this without having to create a document
Async methods with an RenderMVCController have not been a happy couple. General approach would be not to call the Index() action at all and make your actions async by targeting the template’s action which take precedence over the default Index action.
To do this without a document might make it even harder.
Still, the following links provide information and explain several workarounds.
http://www.digbyswift.com/blog/2015/10/asyncawait-in-umbraco-custom-controllers/
https://our.umbraco.org/forum/developers/extending-umbraco/66777-implementing-an-async-custom-controller-in-umbraco-7
https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/64076-Async-RenderMvcController
https://our.umbraco.org/forum/developers/api-questions/75388-async-form-post-throws-exception
Actually the Async index works perfectly fine, its the LoggedIn action that is not working. Index has a document though.
In that case, it looks like the ChildActionOnly or Authorize attribute is preventing you from accessing it.
In order to check if the routing itself is working correctly, could you temporarily remove the ChildActionOnly attribute in order to see if your LoggedIn action will be called. If that doesn't work, try also removing the Authorize attribute. (I know ... it's ugly but it's only temporarily)
In case it is being called succesfully, the next step will be to find out how the attributes can be used successfully or search for a workaround for that.
Further, you say that Index has a document. Do you mean by that, that you have a document type (named SignInCallback) that does have a template? If it has a template, what's the name of that template?
If it's named LoggedIn, I would expect the LoggedIn action of the controller to be accessible via default Umbraco routing.
If it's not named LoggedIn and/or you don't want a template, you probably need to define a ContentFinder ( https://our.umbraco.org/documentation/reference/routing/request-pipeline/IContentFinder ) but that would mean you need somewhere a node to be available to map to.
I Ended up using a node anyways, but i'm not really liking that i have to create documents for somethin in umbraco that the user is not supposed to see
Hi Kenneth,
It does indeed not feel right to have to create a document if that document has no use at all.
What I do not understand yet is what you would like the LoggedIn method to return. If I understand you correctly it returns something that you do not want to be managed by Umbraco. (Otherwise, if that content would be managed within the Umbraco pipeline, a node would make sense ... right?)
Still, it would surprise me if it cannot be solved in a more sensible way.
Have you considered using a user defined route?
If not, please have a look at: https://our.umbraco.org/documentation/Reference/Routing/custom-routes.
Further, there's also something called a UmbracoVirtualNodeRouteHandler that could lead to an appropiate solution.
is working on a reply...