重定向使用ASP.NET MVC偏查看表单提交参考 [英] Redirect to Refer on Partial View Form Post using ASP.NET MVC

查看:148
本文介绍了重定向使用ASP.NET MVC偏查看表单提交参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一个最佳实践的建议。

I'm looking for a best practice suggestion.

我有一个ShoppingBag控制器具有部分列出在用户的袋子中的所有项目。在这个部分,你可以通过表单POST从包装袋中取出物品。

I've got a ShoppingBag Controller with a Partial that lists all the items in the user's bag. In this Partial you can remove items from the bag via a form post.

该部分已经发生在一个母版页这是由每个控制器上的意见的引用。当一个项目从用户的袋中取出,我想用户重定向到原始视图。我很高兴我将如何使用JavaScript实现这一点,就非JavaScript的,我不清楚。

The Partial has been place in a Master Page which is referenced by each of the Views in the Controller. When an item is removed from the user's bag, I'd like the user to be redirected to the originating View. I'm quite happy with how I would achieve this with JavaScript, it is the non JavaScript I am not clear about.

我:


  1. 检测使用Request.UrlReferrer转诊行动和重定向。这可能是相当费力检测从URL动作/路由。

  2. 传递一个隐藏字段与邮政。没有真正热衷于腹胀的HTML的想法。

  3. 请不要重定向到鼻祖,重定向到一个确认页面。将preFER尽量避免。

  4. 的东西我已经错过了。

任何帮助将AP preciated。

Any helped would be appreciated.

推荐答案

绝对#2。它不膨胀,这是前pressing你的意图。这将是50个字节,不出汗,你应该反正gzip'ing您的HTTP。

Definitely #2. It's not bloat, it's expressing your intent. It'll be 50 bytes, don't sweat it, you should be gzip'ing your HTTP anyway.

但是,请确保你保护它,这样的人不能把任何旧的网页在那里,或其他网站。如果始发视图的数量被限制或者使用一个枚举值。

However, do make sure that you secure it such that someone can't put any old page in there, or another site. Perhaps use an enum value if the number of originating views is constrained.

这篇关于重定向使用ASP.NET MVC偏查看表单提交参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆