PDA

View Full Version : حرفه ای: 500 - Internal server error



hmahdavi921
پنج شنبه 12 بهمن 1396, 11:22 صبح
سلام
در سایت از custom routing استفاده کردم و درست کار میکنه الان یک webapi controller هم به پروژه اضافه کردم که برای مسیر یابی متدهای webapi در فایل Global.ascx این کد
protected void Application_Start() {
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.F ilters);
GlobalConfiguration.Configure(RouteConfig.WebApiCo nfig.Register);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}

و در app start این کد رو نوشتم :

public static class WebApiConfig {
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
الان روتینگ سایت در لوکال کاملا درسته و بدون ایراد کار میکنه اما وقتی فایل DLL پروژه رو به سرور منتقل میکنم این خطا رو میده :

Server Error


500 - Internal server error.

There is a problem with the resource you are looking for, and it cannot be displayed.




بارها فایل رو مجدد build کردم و به سرور آپلود کردم اما نتیجه نگرفتم البته چند بار که کد

GlobalConfiguration.Configure(RouteConfig.WebApiCo nfig.Register);

رو کامنت کردم سایت کار کرد
لطفا راهنمایی بفرمائید

RIG000
چهارشنبه 18 بهمن 1396, 17:10 عصر
سلام
در سایت از custom routing استفاده کردم و درست کار میکنه الان یک webapi controller هم به پروژه اضافه کردم که برای مسیر یابی متدهای webapi در فایل Global.ascx این کد
protected void Application_Start() {
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.F ilters);
GlobalConfiguration.Configure(RouteConfig.WebApiCo nfig.Register);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}

و در app start این کد رو نوشتم :

public static class WebApiConfig {
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
الان روتینگ سایت در لوکال کاملا درسته و بدون ایراد کار میکنه اما وقتی فایل DLL پروژه رو به سرور منتقل میکنم این خطا رو میده :

Server Error


500 - Internal server error.

There is a problem with the resource you are looking for, and it cannot be displayed.




بارها فایل رو مجدد build کردم و به سرور آپلود کردم اما نتیجه نگرفتم البته چند بار که کد

GlobalConfiguration.Configure(RouteConfig.WebApiCo nfig.Register);

رو کامنت کردم سایت کار کرد
لطفا راهنمایی بفرمائید
این قطعه کد رو بزار

<configuration> <system.web> <customErrors mode="Off"/> <compilation debug="true"/> </system.web> </configuration>

رو در وب کانفیگ بزار و ببین که دقیقا متن ارور رو بهت میده و میتونی ببینیش

hmahdavi921
شنبه 21 بهمن 1396, 12:13 عصر
<system.web> <authentication mode="None" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<httpCookies requireSSL="true" />
<customErrors mode="Off" />
</system.web>
این کدها رو در وب کانفیق دارم ولی بازم نشون نمیده
147624