c# mvc 3, action overloading?

后端 未结 1 1996
不思量自难忘°
不思量自难忘° 2020-12-16 02:56

I have been trying to overload my index method.

Here are my index methods:

[ActionName(\"Index\")]
public ActionResult IndexDefault()
{
}

[ActionNam         


        
相关标签:
1条回答
  • 2020-12-16 03:48

    Overloading like that isn't going to work.

    Your best option is to use default values and then making the route values optional (like you already have them):

    public ActionResult Index(string eventName = null, string language = null)
    {
    }
    

    I'm not sure you're going to get the route to look the way you want with a single route definition though. You're probably going to have to define three different routes and map each back to your single Action method.

    0 讨论(0)
提交回复
热议问题