ASP.NET MVC找出主叫方的方法时!ModelState.IsValid [英] ASP.NET MVC Finding out the caller to a method when !ModelState.IsValid

查看:163
本文介绍了ASP.NET MVC找出主叫方的方法时!ModelState.IsValid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个返回一个ActionResult我的CartController的AddtoCart操作方法。我遇到的问题是,我从antoher控制器到AddtoCart我要添加的产品的ID后,然后继续前进。我有一个验证没有问题;但是,它的时候我想重定向到调用操作时查看了!ModelState.IsValid,我不知道是谁给我打电话(或在哪里可以找到它)。

I have action method on my "CartController" an AddtoCart that returns an ActionResult. The problem I'm having is that I post from antoher controller to the AddtoCart the Id of the product i want to add, then move on. I have no problem with the validation; however, it's when I want to redirect to the View that called the Action when the !ModelState.IsValid, that I don't know who called me (or where to find it).

这可能是几个不同的控制器可以张贴的方法。是否有什么东西在ViewData的,我可以用它来findout谁打电话给我的行动方法?

It is possible that several different controllers may post to the method. Is there something in the ViewData that I can use to findout who called my Action Method?

推荐答案

听起来像你对我是后:

Request.UrlReferrer

让我知道,如果你不是。

Let me know if you're not.

HTHS,

查尔斯

HTHs,
Charles

这篇关于ASP.NET MVC找出主叫方的方法时!ModelState.IsValid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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