I have 2 MVC3 Razor sites I am working on and both sites are using IIS6.5 (Which I hope is the route cause of this problem). Both of them I have used the natural class abilities to call methods for setting up and object then redirecting to another action. example:
public ActionResult ApprovePlan(decimal id)
{
PPS_PLAN_TBL.ApprovePlan(id, UserId);
PPS_PLAN_TBL ppsPlanTbl = db.PPS_PLAN_TBL.Single(p =>
p.PpsPlanIdentifier == id
);
EMPLEE_TBL executive = dbEmployees.EMPLEE_TBL.Single(n =>
n.EmployeeUserIdentifier == ppsPlanTbl.ExecutiveUserIdentifier
&& n.PayPeriodIdentifier == CurrentPayPeriod
);
EMPLEE_TBL ro = dbEmployees.EMPLEE_TBL.Single(n =>
n.EmployeeUserIdentifier == ppsPlanT开发者_JS百科bl.RatingOfficialUserIdentifier
&& n.PayPeriodIdentifier == CurrentPayPeriod
);
return RedirectToAction("Index");
}
As you can see that receives an Id and sets the record to be approved. It is called by an actionlink on the index page:
<a href='@Url.Action("ApprovePlan", "PerformancePlanSystem", new { Id = item.PpsPlanIdentifier })' title="Approve Plan"><img src="@Url.Content("~/Content/images/thumbsup.png")" alt="Approve Plan" height="16" width="16" /></a>
The issue in all of these is that the first time I fire a call it works the first time but all subsequent calls actually go to the destination of the action as if the controller know the ultimate destination, ignores the action (It will not get caught with a breakpoint) and gos directly to that action. Its quite irritating and I cant figure out why it does it. I do know it is session related because if I close my browser and reopen it the link works again..1 time. I think I could fix this by attaching a real view (.cshtml) to all my actions but that would be a pain because they would do nothing and for 508 compliance I would be forced to have a quirky app.
I doubt anyone outside of MS can explain this behavior but at the very least I am wondering if anyone else is seeing this since I have it happening on 3 different servers in 2 different environments running 2 different applications.
Sounds like a caching issue of some sort to me. I suggest you look into that.. I will have a quick look now too and report back
Are you using IE? this one could help:
How to stop MVC caching the results of invoking an action method?
Or maybe this one is more reliable (and easier):
How can I disable client side and proxy caching in ASP.NET MVC?
精彩评论