简体   繁体   中英

Why my overload controller methods not hitting properly?

I have view name called PrintPatientConsent.aspx . I need to call it for two types.

But, by default only default action method only called. even though i passed parameters.

For your reference:

 [AcceptVerbs("GET")]
 public ActionResult PrintPatientConsent()
 {
   ----
 }

 [AcceptVerbs("GET")]
 [ActionName("PrintPatientConsent")] // i tried to pass action name
 public ActionResult PrintPatientConsent(int id)
 {
   ------
 }

Javascript:-

Ex-Code:

url = '/Emr/Patients/PrintPatientConsent?Id=' + idd; //where i'm calling Parameterized actionmethod
TopUp.display(url)

Can any one please help me to find out the solution.., thanx in advance.

One of the solutions is

    public ActionResult PrintPatientConsent(int? id)
    {
        if(id == null) {
            // case A
        }
        else {
           // case B
        }
    }

You can also use the method selection attribute: The current request for action {0} on controller type {1} is ambiguous

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM