Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,
I am struggling to code the following method, as I would like to pass data from the "Values controller" into the "user controller". The values controller returns a model of data, I would like to seek help/advice, how can pass the values model data into the user controller.
C#
public class UserController : ApiController
    {
       [Authorize(Roles = "admin")]
        public void Get()
        {
               var result = new ValuesController();
               return result.Get();
              

        }

C#
public class ValuesController : ApiController
{
// GET api/values

public IEnumerable<string> Get()
{

return new string[] { "value1", "value2" };
}


Many thanks.
Posted
Comments
Member 10476757 31-Jan-14 5:31am    
try by removing return in get()

1 solution

You can't return a value in a void method!
C#
public void Get()
{
       var result = new ValuesController();
       return result.Get();
}
You would have to declare it as returning a IEnumerable<string>:
C#
public IEnumerable<string> Get()
{
       var result = new ValuesController();
       return result.Get();
}
 
Share this answer
 
v2
Comments
[no name] 31-Jan-14 5:37am    
5+ as always..;)
miss786 31-Jan-14 6:04am    
Thank you very much for your solution and hardwork. Its working as expected.
Many thanks.
OriginalGriff 31-Jan-14 6:31am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900