ASP.NET MVC WebAPI 404 error

前端 未结 8 1450
一生所求
一生所求 2020-12-13 23:31

I have an asp.net web forms application running under v4.0 integrated mode.

I tried to add an apicontroller in the App_Code folder.

In the Global.asax, I ad

8条回答
  •  感情败类
    2020-12-14 00:30

    Ensure the following things

    1.) Ensure that your IIS is configured with .NET 4.5 or 4.0 if your web api is 4.5 install 4.5 in IIS

    run this command in command prompt with administrator privilege

    C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -i
    

    2.) Change your routing to

    RouteTable.Routes.MapHttpRoute(
          name: "DefaultApi",
          routeTemplate: "{controller}/{id}",
          defaults: new { id = System.Web.Http.RouteParameter.Optional }
     );
    

    and make request with Demo/Get (where demo is your controller name)

    if the 1,2 are not working try 3

    3.) Add following configuration in web.config file

    
        
    
    
    

提交回复
热议问题