depending on what should happen on your ajax call I would suggest to not use the RenderMvcController which is returning a model that inherit from RenderModel. Instead I would suggest to use a SurfaceController for your ajax request and then return a normal model that don't inherit the RenderModel.
Hi, David and Alex;
Thanks for your response.
Yes, I fixed the issue. I used SurfaceController as David said.
"stuck" is because "Umbraco.Web.UmbracoContext.Current.PublishedContentRequest" is null.
For some reasons there is no "null" exception thrown.
Still cannot figure out why it is "null".
Just have a new case that "PublishedContentRequest" is null.
Please have a look my latest post regarding this issue if you have interest.
HI, Alex;
I agree Jason is quicker. But I don't think this is the problem: PublishedContentRequest = null.
I think I don't use the controller and RenderModel properly.
First of all when you are using a surface controller then the model shouldn't inherit from render model. Thats only necessary when you are using a RenderMvcController.
Second the view you are returning in your surface controller should not have a layout page. It should only be a partial.
Returning a json from the controller only makes sense if you want to change everything dynamically. When it should be called on the first time the page loads a view with a model should be fine.
HI, David;
Yes, I think you are right. I should not use SurfaceController.
My HomePage is a "registered" Umbraco Page created in back office. I use RenderMvcController. The second page is not from Umbraco, it is created by my self (except the layout page that inherits from UmbracoTemplatePage). I think that why "PublishedContentRequest" is null.
If I create a content in back office as my second page then I believe this will fix the issue.
I get around this issue by NOT inheriting my view model from RenderModel and have a different layout. This looks more like a traditional MVC page.
Inherit from RenderModel
Hi, there; I am developing a view that use ajax call from a view
... ... ... }
When my code steps into the constructor calling "base(Umbraco.Web......)", the program just stuck there, never return, looks be "swallowed"
Can someone help what is happening here?
THX.
Robert
Hi Robert,
Did you find solution?
Thanks,
Alex
Hi Robert,
depending on what should happen on your ajax call I would suggest to not use the RenderMvcController which is returning a model that inherit from RenderModel. Instead I would suggest to use a SurfaceController for your ajax request and then return a normal model that don't inherit the RenderModel.
Regards David
Thanks David. Agree with you - don't need to use RenderMvcController for AJAX, another solution will be UmbracoApiController.
I think UmbracoApiController is the best for working with AJAX requests.
Thanks,
Alex
Hi, David and Alex; Thanks for your response. Yes, I fixed the issue. I used SurfaceController as David said. "stuck" is because "Umbraco.Web.UmbracoContext.Current.PublishedContentRequest" is null. For some reasons there is no "null" exception thrown. Still cannot figure out why it is "null". Just have a new case that "PublishedContentRequest" is null. Please have a look my latest post regarding this issue if you have interest.
Cheers Robert.
Hi Robert,
Can you share your code?
Are you trying to return binded view from controller?
Thanks,
Alex
Sure. Yes, I am trying to return a binded view:
I am now using SurfaceController.
Navigation:
Action:
My Index View:
}
Robert, maybe you can use json for returning data and bind it via JS?
I would use JSON via AJAX, its faster and better in any case.
But you have to write some piece of code.
Thanks,
Alex
HI, Alex; I agree Jason is quicker. But I don't think this is the problem: PublishedContentRequest = null. I think I don't use the controller and RenderModel properly.
Cheers Robert.
Hi Robert,
I think there are some missconceptions here.
First of all when you are using a surface controller then the model shouldn't inherit from render model. Thats only necessary when you are using a RenderMvcController.
Second the view you are returning in your surface controller should not have a layout page. It should only be a partial.
Returning a json from the controller only makes sense if you want to change everything dynamically. When it should be called on the first time the page loads a view with a model should be fine.
Regards David
Hi David,
Thanks, agree with you with all except JSON )) I think all data returning via AJAX is better to transfer with JSON.
But sometimes it's ok to use partial views. For example when rendering is hard operation and we need to use serverside caching of html.
Thanks,
Alex
HI, David; Yes, I think you are right. I should not use SurfaceController. My HomePage is a "registered" Umbraco Page created in back office. I use RenderMvcController. The second page is not from Umbraco, it is created by my self (except the layout page that inherits from UmbracoTemplatePage). I think that why "PublishedContentRequest" is null. If I create a content in back office as my second page then I believe this will fix the issue. I get around this issue by NOT inheriting my view model from RenderModel and have a different layout. This looks more like a traditional MVC page.
Cheers, Robert
is working on a reply...