質問

How can I return two views from an action?

I tried as below but I got an error.

public ActionResult Page()
{
    //LINQ x expressions
    //LINQ y expressions
    if (Request.QueryString["type"] == "x")
    {
        return View(linqExpX.ToList());
    }
    else if (Request.QueryString["type"] == "y")
    {
        return View(linqExpY.ToList());
    }
}
役に立ちましたか?

解決

Not all parts of your code return a value..

Try this code:

public ActionResult Page()
{
    //LINQ x expressions
    //LINQ y expressions
    if(Request.QueryString["type"] == "x")
    {
        return View(linqExpX.ToList());
    }
    else if(Request.QueryString["type"] == "y")
    {
        return View(linqExpY.ToList());
    }

    return someDefaultView; 
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top