Showing posts from October, 2014

Remote access to IIS Express

If you try to access the IIS Express website from a remote computer, you wont be able to do it unless you follow these steps.


Look for <sites> section
In there find your site

<site name="MyWeb" id="2"> <application path="/" applicationPool="Clr4IntegratedAppPool"> <virtualDirectory path="/" physicalPath="E:\MyWeb" /> </application> <bindings> <binding protocol="http" bindingInformation="*:52891:localhost" /> <binding protocol="http" bindingInformation="*:8080:" /> </bindings> </site>
Now, create another binding as highlighted. IP address is your computers' IP, port is whatever the port you want.

Allow incoming connections: Open command prompt as admin
netsh http add urlacl url= u…

Web API 2 - Route Not Found (404)

It worked before, now it doesn't?

Here's the checklist.

Web API routes registration.
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); GlobalConfiguration.Configure(WebApiConfig.Register); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
Web API config should come before normal Routes.
Route Prefix change [Route("~/api/sendemail")] to [Route("/api/sendemail")]
Prefix "~" is not needed.
Route values[Route("{myId:int}/sendemail")][HttpPost()]public bool SendEmail(int id,ContactModel data){returnOk();} notice the route defines a myId but method accepts an id. This will give a 404 Change the id or myId like this for it to work.