简体   繁体   中英

A public action method was not found on controller

I am working on a project on asp.net MVC3, I have a controller named UserProfile when i run my project and login, it shows error A public action method images was not found on controller UserProfile

I don't have any action method named images in any of my controllers,below is my UserProfile's index method

[CustomAuthorizeAttribute]
    public ActionResult Index()
    {
        var userName = string.Empty;
        if (SessionHelper.GetSession("login") != null)
        { userName = SessionHelper.GetSession("login").ToString(); }
        else
        { return View(); }

        SessionHelper.SetSess("issetup", null);
        UserProfileModel model = GetUserProfileData(userName);
        StateandCityDropdown();
        return View(model);
    }

I have two forms on userprofile index view one with some textboxes and other fields for entering data and second for uploading images

It sounds to me like the routes are picking up on a url you have and mistaking them for an action. It could be that you have a link to an image directory underneath a directory that matches your controller such as /User/Images would thow this error because the routing would then expect you to have an Images action when you dont. Check the page source for anything linking to an images folder but without an image included. The other option is that the routes are picking up the images as well as the actions you want them to. If this is the case in your Global.asax.cs file check the RegisterRoutes method has some ignores in for images.

       routes.Ignore("{*allpng}", new { allpng = @".*\.png(/.*)?" });
       routes.Ignore("{*allgif}", new { allgif = @".*\.gif(/.*)?" });
       routes.Ignore("{*alljpg}", new { alljpg = @".*\.jpg(/.*)?" });

Hope this helps Andy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM