c# - 与 Sammy.js 相关的返回视图问题
问题描述
我正在使用 sammy.js 构建一个 SPA,关于 Sammy 的路由如下;
this.get(/#\/user\/profile/i, function (context) {
titleContent.html("User Profile");
document.title = "User Profile";
getPage("#/user/profile", "/User/Profile", context);
});
我有一个 GET 和 POST 视图,用于更新用户帐户的信息;
[Authorize, HttpGet, Route("User/Profile")]
new public ActionResult Profile()
{
//do some stuff
return View(vm);
}
[HttpPost, Authorize, Route("User/Profile")]
new public ActionResult Profile(UserProfileViewModel vm)
{
if (!ModelState.IsValid)
return View(vm);
//other code if valid modelstate
return View(vm);
}
现在,然后!Modelstate.IsValid,它将视图返回为“/User/Profile”,而不是“/#/User/Profile”。
如何使用已使用错误消息更新的 ViewModel 返回实际的 Sammy 注册路由(“/#/User/Profile”)?
解决方案
推荐阅读
- ios - iOS - Pushnotification 快过期后怎么办?
- javascript - jQuery 结合 id、class 和多个属性选择器
- android - 如何创建一个通用的 Repository 类?(安卓)
- cmake - 安装 EBU R128 响度扫描仪时出现问题
- vue.js - Vue.js - 在 mixins 中声明 props 和数据字段
- dependencies - GNU Make:如何在单个 define..endef 块中设置两个或多个依赖目标?
- ios - 使用 RobotFramework 在 iOS 中进行自动化测试
- java - 如何为 Java 代码强制执行标准样式?
- javascript - 图片上传并转换为base64后,AngularJS v1.5.0 ng-model不起作用
- javascript - 为什么 jquery 不响应我的条件?