0

I have just completed a site LostPetListings.com that has partial views within the master layout. I have a partial view "Create Account" that has remote validation on the Email property that works fine. I even can see the data-val-remote-url="/en-us/Validation/EmailExists" in the html, it tests fine when examining the request using Firebug. Problem: I'm getting a ton of errors for "No url for remote validation could be found." when Googlebot hits the site? I can't understand why? An email that exists in db is [email protected] to test it..

My Model:

[Required(ErrorMessageResourceType = typeof(SharedStrings), ErrorMessageResourceName = "EmailRequired")]
[MyRemote("EmailExists", "Validation", "", ErrorMessageResourceType = typeof(SharedStrings), ErrorMessageResourceName = "EmailAlreadyExists")]
public string Email { get; set; }

My Attribute:

 public class MyRemoteAttribute : RemoteAttribute
    {
        public MyRemoteAttribute(string action, string controller, string area)
            : base(action, controller, area)
        {
            this.RouteData["area"] = area;
        }
    }

Validation Controller decorated with:

 [OutputCache(Location = OutputCacheLocation.None, NoStore = true)]

Validation Controller Action:

 [HttpGet]
         public JsonResult EmailExists(string Email)
        {
            string culture = RouteData.Values["culture"]==null?"en-us":RouteData.Values["culture"].ToString().Replace("_", "-").ToLower();

            if (Email != "" && SecurityHelper.ReferrerIsValid) 
            {
                EndUser_Translated eut = endUserTranslatedRepository.Get(d => d.EndUser.Email == Email.Trim() && d.Culture == culture);

                if(eut==null)
                    return Json(true, JsonRequestBehavior.AllowGet);
                else
                    return Json(SharedStrings.EmailAlreadyExists, JsonRequestBehavior.AllowGet);

            }
            else
                return Json(SharedStrings.EmailAlreadyExists, JsonRequestBehavior.AllowGet);

         }

How Partial is loaded in Master layout:

@Html.Partial("_CreateAccount", new RegisterModel())

Everything works great so can't understand why I'm getting this error 'many' from bots [looked up IP I'm catching with error in error log... Googlebot especially]? Might it have something to do with partials cached in master layout or something? Any ideas/guesses welcome even if not correct in the end as it may bring to mind something..

2
  • System.InvalidOperationException: No url for remote validation could be found. at System.Web.Mvc.RemoteAttribute.GetUrl(ControllerContext controllerContext) at System.Web.Mvc.RemoteAttribute.d__0.MoveNext() at System.Linq.Enumerable.d__711.MoveNext() at System.Linq.Enumerable.d__142.MoveNext() at System.Web.Mvc.HtmlHelper.GetUnobtrusiveValidationAttributes(String name, ModelMetadata metadata) at System.Web.Mvc.Html.InputExtensions.InputHelper(HtmlHelper htmlHelper, InputType inputType, ModelMetadata metadata, String name, Object value, Boolean useViewData, Boolean isChecked, ...
    – Bryant
    Feb 14, 2012 at 23:28
  • I think I found what was happening!!! I had an exception that was erasing the RouteValues.Values["Culture"] in my routes...the cached page was showing the correct culture in the url..but on any navigation my culture was gone....so the problem was upstream from this original suspect issue. I think I'm good now as the error emails have stopped. I'll know within the hour for sure.
    – Bryant
    Feb 15, 2012 at 1:52

1 Answer 1

0

That was it...I had an exception that was erasing the RouteValues.Values["Culture"] in my routes...the cached page was showing the correct culture in the url..but on any navigation my culture was gone....so the problem was upstream. In short, if a url dependent operation is acting weird check your route table..? It helped me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.