MVC Widget Hybrid Mode on Home Page

Posted by Community Admin on 04-Aug-2018 02:29

MVC Widget Hybrid Mode on Home Page

All Replies

Posted by Community Admin on 20-Jun-2014 00:00

I'm having issues with a MVC widget. It's a Registration form that sits on the home page.

The controller is similar to:

01.[ControllerToolboxItem(Name = "RegisterForInterestMvc", Title = "RegisterForInterestMvc", SectionName = "MvcWidgets"), Telerik.Sitefinity.Web.UI.ControlDesign.ControlDesigner(typeof(Em2.SitefinityWebApp.WidgetDesigners.RegisterForInterestMvc.RegisterForInterestMvcDesigner))]
02.    public class RegisterForInterestMvcController : Controller
03.    
04.        /// <summary>
05.        /// Gets or sets the message.
06.        /// </summary>
07.        [Category("String Properties")]
08.        public string Message get; set;
09. 
10.        /// <summary>
11.        /// This is the default Action.
12.        /// </summary>
13.        public ActionResult Index()
14.        
15.            var model = new RegisterForInterestMvcModel();
16.            if (string.IsNullOrEmpty(this.Message))
17.            
18.                model.Message = "Hello, World!";
19.            
20.            else
21.            
22.                model.Message = this.Message;
23.            
24. 
25.            return View("Default", model);
26.        
27. 
28.        [HttpPost]
29.        public ActionResult Index(RegisterForInterestMvcModel model)
30.        
31.            //do stuff here
32. 
33.            return View("Success", model);
34.        
35.    

The Default.cshtml and Success.html files are under the ~/Views/RegisterForInterestMvc folder in the solution.

Two issues occur:

  1. When I access the page from http://mywebsite the post works but it is redirect to the Success view with no master page or theming
  2. When I access the page from the Home page link the navbar I get a 404 error "Can't find http://mywebsite /index?<somequerystringhere>

The only way I can route to my success page is by changing the Post action to 

1.[HttpPost]
2.public ActionResult Index(RegisterForInterestMvcModel model)
3.
4.    //do stuff here
5. 
6.    return Redirect("~/Index/Success?"+queryStringBuilt);
7.

 

Which results in a page url which is ugly mywebsite/.../success

How can I create more user friendly routes in Hybrid mode?

Posted by Community Admin on 20-Jun-2014 00:00

Hi Craig,

You can use an attribute like [ActionName("Success")] on any action to make it listen for that route value.

Another way to control what happens it to override the protected method called HandleUnknownAction and implement logic that decides what to render based on whatever action is requested.

Regards,
Boyko Karadzhov
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 20-Jun-2014 00:00

Thanks for the information it certainly helped on non home pages but the issue on the home page still persists with both suggestions.

When I click home from the navigation menu and then click submit the form posts to localhost:60876/Index and I get a 404

Posted by Community Admin on 24-Jun-2014 00:00

Hi Craig,

This is a known issue at our end and we already have it logged internally.
However, I made a feedback item for you in our feedback portal, so that you can track the issue yourself:
http://feedback.telerik.com/Project/153/Feedback/Details/131773-mvc-widget-that-performs-redirect-on-httppost-doesnt-work-if-you-access-the-hom
Let me know if I can be of further help to you.

Regards,
Svetoslav Petsov
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed