【发布时间】:2017-06-24 05:04:24
【问题描述】:
这是一个 MVC 剃须刀页面,在首次加载时运行良好。 如果我使用 javascript 重新加载,甚至在浏览器菜单 (Chrome) 中刷新,我会得到 “/”应用程序中的服务器错误。
>The view 'actionChangeUserSentence' or its master was not found or no view
>engine supports the searched locations. The following locations were searched:
>~/Views/Conduct/actionChangeUserSentence.aspx
>~/Views/Conduct/actionChangeUserSentence.ascx
>~/Views/Shared/actionChangeUserSentence.aspx
>~/Views/Shared/actionChangeUserSentence.ascx
>~/Views/Conduct/actionChangeUserSentence.cshtml
>~/Views/Conduct/actionChangeUserSentence.vbhtml
>~/Views/Shared/actionChangeUserSentence.cshtml
>~/Views/Shared/actionChangeUserSentence.vbhtml
> and so on...
表示 url 字符串被认为是非 MVC url。 我尝试了几种重新加载的可能性,包括:
-location.reload();
-window.location.reload(false); with both false and true
-location.href = location.href;
-history.go(0);
顺便说一句,我需要刷新的原因是 js 在 html 画布上绘图不起作用,除非在整页(重新)加载后,原因仍然未知。但无论如何,浏览器菜单刷新当然应该总是有效的,我猜...... 感谢您的帮助。
【问题讨论】:
-
您尝试重新加载的视图名称是“actionChangeUserSentence”吗?这可能是一个被重新调用的 Post 请求而不是视图的获取?
-
不,想要的视图与重新加载之前的原始视图相同。
-
@Hopeless:不,想要的视图与重新加载之前的原始视图相同。
-
在 Chrome 的地址栏中,首次加载时显示为:“localhost:13062/Conduct/Conduct?...”。当我的 cshtml 行 @using (Ajax.BeginForm("actionTryGetNewSystemSentence", "Conduct", new AjaxOptions { HttpMethod = "POST", OnSuccess = "OnTryGetNewSystemSentenceSuccess(data)" })) 稍后变为活动状态时,它会调用,验证,我的 js 函数 OnTryGetNewSystemSentenceSuccess(data)
-
而且这个函数本身不会自动导致重新加载,但是,在这个函数中的一些必要但简单的命令之后,我尝试通过 js 行“jQuery.post( '@Url.Action("actionJustReload", "Conduct")');"我希望调用 //[HttpGet] //[HttpPost] public ActionResult actionJustReload() { return View(); }
标签: razor model-view-controller reload