Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sharmarke Hujale 103 posts 346 karma points
    May 16, 2016 @ 12:38
    Sharmarke Hujale
    0

    No route in the route table matches the supplied values.

    Hi guys,

    I've a big problem with getting this contact form to work with html.action

    Here's my ContactFormSurfaceController.cs:

    public class ContactFormSurfaceController : SurfaceController
    {
    
        public ActionResult ShowContactForm()
        {
            return PartialView("ShowContactForm", new ContactFormViewModel());
        }
    
    }
    

    Here's my ContactFormViewModel.cs:

    public class ContactFormViewModel
    {
        [Required]
        public string Navn { get; set; }
    
        [Required]
        [EmailAddress]
        public string Email { get; set; }
    
        [Required]
        public string Emne { get; set; }
    
        [Required]
        public string Besked { get; set; }
    }
    

    That's how I use the Html.Action on Contactsection.cshtml:

     <!------Contact formular--------->
                <div class="form-container">
                    @Html.Action("ShowContactForm", "ContactFormSurface")
                </div>
    

    And this is my ShowContactForm.cshtml page:

    @using Dalada.Controllers
    @using Dalada.Models
    @model ContactFormViewModel
    
    @{
    Html.EnableClientValidation(true);
    Html.EnableUnobtrusiveJavaScript(true);
    }
    
    @if (Convert.ToBoolean(TempData["IsSuccessful"]))
    {
      <p class="thanks text-center">Tak for din besked - vi vil besvare dig hurtigst muligst</p>
    }
    else
    {
    using (Html.BeginUmbracoForm<ContactFormSurfaceController>("HandleContactForm"))
    {
    
        @Html.ValidationSummary(true)
        @Html.AntiForgeryToken()
    
        @Html.ValidationMessageFor(model => model.Navn, "Udfyld venligst dette felt")
        @Html.TextBoxFor(model => model.Navn, new { @class = "form-control", placeholder = "Navn*" })
    
    
        @Html.ValidationMessageFor(model => model.Email, "Udfyld venligst dette felt")
        @Html.TextBoxFor(model => model.Email, new { @class = "form-control", placeholder = "Email*", type = "Email" })
    
        @Html.ValidationMessageFor(model => model.Emne, "Udfyld venligst dette felt")
        @Html.TextBoxFor(model => model.Email, new { @class = "form-control", placeholder = "Emne*" })
    
        @Html.ValidationMessageFor(model => model.Besked, "Udfyld venligst dette felt")
        @Html.TextAreaFor(model => model.Besked, new { @class = "form-control", placeholder = "Besked*" })
    
        <input type="submit" class="btn btn-default" value="send" />
      }
    }
    

    But it always says: "No route in the route table matches the supplied values"

    Hope you guys can help me with this - I've really struggled!

    Thanks in advance

    //Sharmarke

  • Steve Morgan 1349 posts 4459 karma points c-trib
    May 16, 2016 @ 12:59
    Steve Morgan
    0

    Hi Sharmarke,

    It sounds remarkably similar to this issue:

    https://our.umbraco.org/forum/templates-partial-views-and-macros/77127-controllers-different-between-umbraco-7-and-umbraco-743

    Have you included the MVC files in your solution and rebuilt from Visual Studio?

    Kind regards

    Steve

  • Sharmarke Hujale 103 posts 346 karma points
    May 16, 2016 @ 13:33
    Sharmarke Hujale
    0

    Hi Steve,

    Here's my files:

    enter image description here

    When I build the solution it says:

    "There were build erros. Would you like to continue and run the last successful build?"

    And I rebuild the solution it says:

    "Rebuild all failed"

  • Steve Morgan 1349 posts 4459 karma points c-trib
    May 16, 2016 @ 13:42
    Steve Morgan
    0

    Hi,

    There will be more detailed errors that will help you work out what's wrong (usually something has been mis-spelt or an include not correct).

    Looks for the error list tab at the bottom - ignore warnings but ensure the errors option is selected.

    Build errors

  • Sharmarke Hujale 103 posts 346 karma points
    May 16, 2016 @ 13:48
    Sharmarke Hujale
    0

    I got 122 errors and 3 warnings,

    most of the errors comes from a file named models.generated.cs

    Some of the errors:

    enter image description here

    And the warnings:

    enter image description here

  • Steve Morgan 1349 posts 4459 karma points c-trib
    May 16, 2016 @ 13:52
    Steve Morgan
    100

    Have you included in your solution the App_Data/Models folder and all it's contents.

    HINT: don't! This folder is generated at run time and included as Umbraco starts.

    To fix the above right click on the folder and Exclude from Project.

    HTH

    Steve

  • Bahadur 7 posts 78 karma points
    Jun 26, 2019 @ 12:14
    Bahadur
    0

    Hi! I had this issue too. The folder wasn't included but a build did the trick.

  • Rahul 1 post 71 karma points
    Oct 26, 2019 @ 18:12
    Rahul
    0

    Hello All,

    I'm facing the same issue. I have not included app_data in the solution and have checked for typos in the controller/ action multiple times. Can someone help me with this?

  • Steve Morgan 1349 posts 4459 karma points c-trib
    May 16, 2016 @ 13:54
    Steve Morgan
    0

    What might have confused you is in the Views you may see a red squiggly under the Document Type model

    e.g.

    Red squiggly on doc type model

    This is fine and can be ignored.

    Steve

  • Sharmarke Hujale 103 posts 346 karma points
    May 16, 2016 @ 15:52
    Sharmarke Hujale
    0

    It's working now!!! Thanks a lot! I excluded the model folder in App_data folder - I did a clean solution, rebuild and restarted VS and it worked after that,

    but I don't understand where this folder comes from - it wasn't there in my previous projects?

  • Steve Morgan 1349 posts 4459 karma points c-trib
    May 16, 2016 @ 15:57
    Steve Morgan
    0

    The models builder is a new feature in the latest version.

    You can switch it off -

    http://www.zpqrtbnk.net/posts/purelive-models-introduction

  • Sharmarke Hujale 103 posts 346 karma points
    May 16, 2016 @ 17:36
    Sharmarke Hujale
    0

    Thanks!

    Can you help me with another minor problem, steve?

    enter image description here

    I haven't event clicked the send button and yet it shows the validations errors to me

    This is my contact form:

    @using Dalada.Controllers
    @using Dalada.Models
    @model ContactFormViewModel
    
    @{
        Html.EnableClientValidation(true);
        Html.EnableUnobtrusiveJavaScript(true);
     }
    
    @if (Convert.ToBoolean(TempData["IsSuccessful"]))
    {
    <p class="thanks text-center">Tak for din besked - vi vil besvare dig    hurtigst muligst</p>
    }
    
    else
    {
    using (Html.BeginUmbracoForm<ContactFormSurfaceController>("HandleContactForm"))
    {
    
        @Html.ValidationSummary(true)
        @Html.AntiForgeryToken()
    
        @Html.ValidationMessageFor(m => m.Navn, "Udfyld venligst dette felt", new { @class = "text-danger" })
        @Html.TextBoxFor(m => m.Navn, new { @class = "form-control", placeholder = "Navn*" })
    
        @Html.ValidationMessageFor(m => m.Email, "Udfyld venligst dette felt", new { @class = "text-danger" })
        @Html.TextBoxFor(m => m.Email, new { @class = "form-control", placeholder = "Email*", type = "Email" })
    
        @Html.ValidationMessageFor(m => m.Emne, "Udfyld venligst dette felt", new { @class = "text-danger" })
        @Html.TextBoxFor(m => m.Emne, new { @class = "form-control", placeholder = "Emne*" })
    
        @Html.ValidationMessageFor(m => m.Besked, "Udfyld venligst dette felt", new { @class = "text-danger" })
        @Html.TextAreaFor(m => m.Besked, new { @class = "form-control", placeholder = "Besked*" })
    
        <input type="submit" class="btn btn-default" value="send" />
     }
    }
    
  • Steve Morgan 1349 posts 4459 karma points c-trib
    May 16, 2016 @ 18:53
    Steve Morgan
    0

    I think you'd be best to start a new thread - I have a vague recollection that this can happen with Unobtrustive validation if you haven't correctly correctly included the JS libraries on the template though.

    Kind regards

    Steve

  • Sharmarke Hujale 103 posts 346 karma points
    May 16, 2016 @ 20:24
    Sharmarke Hujale
    0

    You right, I'll start a new thread instead.

    But thanks for the help before, Steve!

Please Sign in or register to post replies

Write your reply to:

Draft