Startup Controller Action/Argument

May 20, 2012 at 9:41 PM

Can you please explain how to use:-

hostBuilder.Configuration.DefaultControllerActionArguments

.. as I need to start a controller action with an argument as in:-

hostBuilder.Configuration.DefaultControllerAction = "Home.Index";

hostBuilder.Configuration.DefaultControllerActionArguments = ???

The controller has:-

public ActionResult Index(string id)

Thanks.

Coordinator
May 21, 2012 at 7:02 AM

Hey Steve,

hostBuilder.Configuration.DefaultControllerActionArguments = new []{ 1 };

it is simply an object array containing the arguments. I am open to suggestions on how to make this better/more discoverable. Until v1 I am not locking down the API and am fully open to changing any parts of the framework for the better.

Cheers,

Jake

From: stevesuk [email removed]
Sent: Monday, 21 May 2012 5:42 AM
To: Jake Ginnivan
Subject: Startup Controller Action/Argument [phoenixframework:356473]

From: stevesuk

Can you please explain how to use:-

hostBuilder.Configuration.DefaultControllerActionArguments

.. as I need to start a controller action with an argument as in:-

hostBuilder.Configuration.DefaultControllerAction = "Home.Index";

hostBuilder.Configuration.DefaultControllerActionArguments = ???

The controller has:-

public ActionResult Index(string id)

Thanks.

May 21, 2012 at 8:54 AM
Edited May 21, 2012 at 9:04 AM

Ok, I have:-

 hostBuilder.Configuration.DefaultControllerActio = "Home.Startup"  

hostBuilder.Configuration.DefaultControllerActionArguments = new object[] { "test"

};  

My HomeController is:- 

public ActionResult Startup(string id)  

 I get error:-

Can not find action 'Startup' because there is no such public method in controller class or parameters passed with navigation request are not matching method signature.

However, if I put the following method in HomeController the top code will result in a call to this method and no error (doesn't call the method with parameter as it should):-

  public ActionResult Startup()  

 

 

 

 

 

Coordinator
May 21, 2012 at 4:53 PM

Thanks for following this up.

I have found and fixed the issue (I simply was not passing the specified startup args through to the action invocation.

I am working towards a new release, I am on holidays at the moment so it is a little slower than normal, but I hope to have the new packages on nuget within the next week.

Let me know if this is a blocking issue for you, and I will send you some links to the latest packages (build server is not public at the moment, sorry. Will sort this out soon too!).

Cheers,

Jake

From: stevesuk [email removed]
Sent: Monday, 21 May 2012 4:55 PM
To: Jake Ginnivan
Subject: Re: Startup Controller Action/Argument [phoenixframework:356473]

From: stevesuk

Ok, I have:-

hostBuilder.Configuration.DefaultControllerAction = "Home.Startup"; 
hostBuilder.Configuration.DefaultControllerActionArguments = new object[] { "test"};

My HomeController is:-

I get error:-

Can not find action 'Startup' because there is no such public method in controller class or parameters passed with navigation request are not matching method signature.

However, if I put the following method in HomeController the top code will result in a call to this method and no error:-

public ActionResult Startup()


public ActionResult Startup(string id)

May 21, 2012 at 7:41 PM

Ok, I have managed to get round it ... so'll I'll wait.

Have a good holiday as that's important!

Regards,

Steve.