将操作返回到asp.net mvc中

时间:2021-07-14 04:13:13

Why my return to InsertUpdate() from Insert action not working when calling insert action using jQuery load function.It shows following error:

为什么我在使用jQuery加载函数调用插入操作时从Insert操作返回到InsertUpdate()不起作用。它显示以下错误:

The partial view 'Insert' was not found or no view engine supports the searched locations. The following locations were searched:

未找到部分视图“插入”或视图引擎不支持搜索的位置。搜索了以下位置:

~/Views/AppClient/Insert.aspx
~/Views/AppClient/Insert.ascx
~/Views/Shared/Insert.aspx
~/Views/Shared/Insert.ascx
~/Views/AppClient/Insert.cshtml
~/Views/AppClient/Insert.vbhtml
~/Views/Shared/Insert.cshtml
~/Views/Shared/Insert.vbhtml

〜/ Views / AppClient / Insert.aspx~ / Views / AppClient / Insert.ascx~ / Views / Shared / Insert.aspx~ / Views / Shared / Insert.ascx~ / Views / AppClient / Insert.cshtml~ / Views / AppClient /Insert.vbhtml~/ Views / Shared / Insert.cshtml~ / Views / Shared / Insert.vbhtml

public ActionResult Insert()
{
   return InsertUpdate();
}
private ActionResult InsertUpdate()
{
   return PartialView();
}

1 个解决方案

#1


0  

Even though the actual action invoked is InsertUpdate() the context in which it is invoked is still the Insert() method (mainly because action in your routing values would still be insert).

即使调用的实际操作是InsertUpdate(),调用它的上下文仍然是Insert()方法(主要是因为路由值中的操作仍然是插入的)。

Hence, when you don't specify a view to be rendered in your call to PartialView(), the name of the view is based on the current routing data.

因此,如果未指定要在对PartialView()的调用中呈现的视图,则视图的名称将基于当前的路由数据。

Try this instead:

试试这个:

return PartialView("InsertUpdate");

Or manually change the routing data upon invoking InsertUpdate():

或者在调用InsertUpdate()时手动更改路由数据:

public ActionResult Insert()
{
    this.RouteData.Values["action"] = "InsertUpdate";

    return InsertUpdate();
}

#1


0  

Even though the actual action invoked is InsertUpdate() the context in which it is invoked is still the Insert() method (mainly because action in your routing values would still be insert).

即使调用的实际操作是InsertUpdate(),调用它的上下文仍然是Insert()方法(主要是因为路由值中的操作仍然是插入的)。

Hence, when you don't specify a view to be rendered in your call to PartialView(), the name of the view is based on the current routing data.

因此,如果未指定要在对PartialView()的调用中呈现的视图,则视图的名称将基于当前的路由数据。

Try this instead:

试试这个:

return PartialView("InsertUpdate");

Or manually change the routing data upon invoking InsertUpdate():

或者在调用InsertUpdate()时手动更改路由数据:

public ActionResult Insert()
{
    this.RouteData.Values["action"] = "InsertUpdate";

    return InsertUpdate();
}