Hello, I am following the instructions here to set up custom error pages using Sitefinity pages. I realize the linked article is geared toward a Webforms solution, but I'd like to achieve the same results with a pure MVC approach, if possible.
Is it possible to create a custom MVC widget, that can be added to the SF error page, that will return a custom http status code? I have tried a very simple controller that looks like this:
ErrorStatusController : SpotOnControllerBase
"Status Code to return. (integer: e.g., 404)"
"Status Description to return. (e.g., Page Not Found)"
(SystemManager.IsDesignMode && !SystemManager.IsPreviewMode)
"This will return a status code of '0' and a status description of '1'. Edit this control and set the Status Code and Status Description properties to change."
, StatusCode, StatusDescription));
But I'm still always getting a Status of '200'.
Is there some way to have an MVC widget force the return status code?
Thanks in advance for any help!
I was not able to get a widget to set/override the response status code. I'm guessing it's something related to Sitefinity's MVC implementation. I ended up creating a new layout for 404 errors, and adding code to it like this:
Response.StatusCode = 404;
"Page Not Found"
This works for me, but is definitely not ideal, as this requires a separate layout for each error/status code :(. I wanted to have a widget that I could re-use and just specify the code and message as properties on the widget. No luck so far, though I haven't revisited this since upgrading from v8.1.
Hi, I'm newer to mvc....
How do I actually apply the info from the KB article? Am I still making a widget to drop on a page? Is most of the code/logic going in a controller? What will I put in the model and view?
"404 Not Found"
Still can't get it to work. Here is what I did
1- Create new controller ErrorStatusController, Register it [ControllerToolboxItem(Name = "ErrorStatus", Title = "Error Status", SectionName = "CustomCMS")]
public ActionResult Index()
Response.Status = "404 Not Found";
Response.StatusCode = 404;
Response.StatusDescription = "Not Found!";
I had issue registering it, however end up doing it on the backend
2- Adding View Simply just showing <h2>Error Page 404</h2>
3- Add FeatherActionInvokerCustom
4- Update Global.asac adding FeatherActionInvokerCustom.Register(); inside Bootstrapper_Bootstrapped
5- on backend I had (default,404,500), I used it when I were doing on application level that caused some issue logging me out after certain time when I work on backend.
On default, I dropped Error Status mvc and still showing The controller with the name
cannot be resolved.
However, 2 things to mention
1- I didn't update/add anything to web.config
2- I had issue when I create controller saying folder/files exist show all. I fixed that but could be an issue.
Any thought what I'm missing ?
Can you provide sample for handling 404,500 ?