我正在开发一个关于asp.net MVC3的项目,当我运行我的项目并登录时,我有一个名为UserProfile的控制器,它显示错误在控制器UserProfile上找不到公共操作方法图像
我的任何控制器中都没有任何名为images的动作方法,下面是我的UserProfile的索引方法
[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);
}
我在userprofile索引视图上有两个表单,一个带有一些文本框,其他字段用于输入数据,第二个用于上传图像
答案 0 :(得分:0)
在我看来,路线正在拾取你所拥有的网址并将其误认为是一个动作。可能是您有一个指向与您的控制器匹配的目录下的图像目录的链接,例如/ User / Images会发生此错误,因为路由会在您不使用时期望您拥有图像操作。检查链接到图像文件夹但没有包含图像的任何内容的页面源。另一个选择是路线正在拾取图像以及您希望它们执行的操作。如果在Global.asax.cs文件中就是这种情况,请检查RegisterRoutes方法是否对图像有一些忽略。
routes.Ignore("{*allpng}", new { allpng = @".*\.png(/.*)?" });
routes.Ignore("{*allgif}", new { allgif = @".*\.gif(/.*)?" });
routes.Ignore("{*alljpg}", new { alljpg = @".*\.jpg(/.*)?" });
希望这会有所帮助 安迪