[英]Returning to the main view from a partial view when the partial view is invalid
My site will have partial views rendered on each page, to provide search functionality. 我的网站将在每个页面上呈现部分视图,以提供搜索功能。
As this is shared on several pages, and all new pages, I don't want to hard code anything or do anything poking around the HTTP Context to determine which master view to render. 由于这是在多个页面以及所有新页面上共享的,因此我不想硬编码任何东西或在HTTP Context上进行任何操作来确定要呈现的主视图。
As such, I have two questions: 因此,我有两个问题:
Now I realize I can render another full view, like a search results page with a message, but my preference is to have this rendered all in the partial view. 现在,我意识到我可以渲染另一个完整视图,例如带有消息的搜索结果页面,但我的首选是在部分视图中全部渲染。
Thanks in advance. 提前致谢。
Can the form in your partial view use ajax instead of performing a regular POST. 局部视图中的表单可以使用ajax代替常规的POST吗? Then you don't have to worry about where the request came from.
然后,您不必担心请求的来源。
If the ajax post is successful you can redirect the user to the search results page. 如果ajax发布成功,则可以将用户重定向到搜索结果页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.