Friday, 15 February 2013

asp.net web api - SelfHosted AspNet WebAPI With Controller Classes In Different Project -


After "text" itemprop = "text">

I created a Selfhosted ASPNET WebAPI with Visual Studio 2012 (.NET Framework 4.5). I have enabled SSL for WebAPI. It works fine when the controller is defined in the same project.

But when I add a reference to another project, which contains the controller, then gives me the following error:

 No HTTP resource is found Request URI 'https: / Matches the /xxx.xxx.xxx.xxx:xxxx/hellowebapi/tests/ '.  

I have created custom classes for HttpSelfHostConfiguration and MessageHandler.

Any help to solve this problem would be a great time-tasting for me.

Thank you in advance.

"itemprop =" text ">

You have a simple custom assemblies solutioner to ensure that your referenced assembly controller works to check for It is ready to write

After a good post from Philip is about this. Sample:

  class program {static HttpSelfHostServer CreateHost (string address) {// general config HttpSelfHostConfiguration config = create new HttpSelfHostConfiguration (address); // Set up our own assembly resolver where we add assemblies, which we will add customizable resolor assembliesolar = new customsobauser (); Config.SServices.Replace (typeof (IAssembliesResolver), assembly resistor); // Add a route config.Routes.MapHttpRoute (name: "default", routeTemplate: "API / {controller} / {ID}", default: new {controller = "home", id = RouteParameter.Optional}); HttpSelfHostServer Server = New HttpSelfHostServer (config); Server.OpenAsync () Wait () .; Console; light line ("listen + + address); return server;} static zero main (string [] arg) {// and create our host HTTP: HOSTHSSHA server server = Create host (" http: // localhost: 8080 ") ; Console; light line ("press ENTER to exit ..."); Console.ReadLine ();}} public class customsubbliserSolar: default asphalisololver {public override icon & lt; assembly & gt; GetAssemblies () {ICollection & Lt; assembly & gt; base asambelees = Base.getSombilize (); & lt; Legislature & gt; Assemblies = New list & lt; assembly & gt; (base assembly); Var Controllant deduction value = assembly.loadfom (@ "C: \ Libs \ Controller \ Controllers' Library. Dll "); baseAssemblies.Add (controllersAssembly); Return Assemblies;}}    

No comments:

Post a Comment