Creating a new controller - Method must have a return type (error on Create Method)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
Hello,

I'm creating a new controller using the Customer Models.

However, the controller Create Method has an error - 'method must have a return type'. Looked everywhere but can't seem to find the trick...

The controller I'm creating is to display a list of Customers. I have copied the CustomerList Controller from the Nop.Admin project...

Any ideas?

Thanks
11 years ago
It sounds like you are calling a method in the class declaration -outside a method.

For example:
  public class YourController : Controller
  {
      [...]
      
      public ActionResult Create()
      {
          [...]
      }

      // this will cause the error: 'Method must have a return type'
      Created();
  }

The method call must be from within a method or constructor.

.
11 years ago
Hello,

Thanks.

Weird, the problem was a missing project reference to Nop.Admin.Models.Common and Nop.Admin.Models.ShoppingCart (maybe the shopping cart one not needed)

M
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.