0

Content Item url is http://www.mysite.com/us/signup which gives the error as mentioned below,

Error message No url for remote validation could be found.

Validation attribute is on the property in the model is

[Remote("IsStoreExists", "Stores", AdditionalFields = "StoreId", ErrorMessageResourceName = "StoreAlreadyExists", ErrorMessageResourceType = typeof(Resources.Stores._CreateOrEdit))]
public string StoreName { get; set; }

I have tried the mvcbridge's tweak as mentioned here Calling Actions on a Controller via URL using MVCBridge (not the package but the idea regarding adding new route for the controller). Please note I have overriden the HttpApplication in this Umbraco 6.0 Application as public class MvcApplication : UmbracoApplication which invokes the RouteConfig class as below..

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        RouteTable.Routes.MapRoute(
            "Stores", // Route name call it anything you want
            "Stores/{action}/{id}", // URL with parameters,
            new { controller = "Stores", action = "IsStoreExists", id = UrlParameter.Optional }
            );

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
}

It seems it is making effect as the when I comment out the custom route named Stores the blank page comes due to Blank Template in View in Umbraco but when I uncomment route Stores it shows 404 at url http://www.mysite.com/us/stores/

Pls help.

Harsh Baid
  • 7,199
  • 5
  • 48
  • 92

2 Answers2

0

It may just be me, but your configured route isn't the same as the URL you are using. You URL starts with /us/ but this is part of the path is missing from your route, so it would throw a 404.

You could change your route to "us/Stores/{action}/{id}" perhaps and see if that works.

Digbyswift
  • 10,310
  • 4
  • 38
  • 66
0
[Remote("IsStoreExists", "StoresSurface", AdditionalFields = "StoreId", HttpMethod = "POST", ErrorMessageResourceName = "StoreAlreadyExists", ErrorMessageResourceType = typeof(Resources.Stores._CreateOrEdit))]
public string StoreName { get; set; }

The surface controller that would match up is something like the following:

using System.Web.Mvc;

using Umbraco.Web.Mvc;

/// <summary>   Stores controller. </summary>
public sealed class StoresSurfaceController : SurfaceController
{
    /// <summary>   Does the store exist. </summary>
    /// <param name="StoreName"> Name of the store. </param>
    /// <param name="StoreId"> Identifier of the store. </param>
    /// <returns>   true if the store exists, false if not. </returns>
    [HttpPost]
    public JsonResult IsStoreExists(string StoreName, long StoreId)
    {
        return this.Json(true);
    }
}

This is a pattern I use frequently and should address your issue.

Jerode
  • 490
  • 4
  • 15