WEB API 2 Application_Start() 在 dev 上触发但在 iis 服务器上部署时不触发
WEB API 2 Application_Start() firing on dev but not when i deploy on iis server
我没有在网上找到解决方案,所以我在这里尝试,我真的不知道问题是什么,但我使用 .NET 4.5 应用程序池(不是经典的)
当它需要到达其中一个控制器时,我总是会收到 404 错误
当它到达全局文件时,我试图打印出来 - 但它似乎甚至没有到达那里。
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net>
<root>
<level value="INFO"/>
<appender-ref ref="RollingFileAppender"/>
<appender-ref ref="ConsoleAppender"/>
</root>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="c:\ApplicationLogs\CenterInterface\mylogfile.txt"/>
<appendToFile value="true"/>
<rollingStyle value="Size"/>
<maxSizeRollBackups value="5"/>
<maximumFileSize value="10MB"/>
<staticLogFileName value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{dd/MM/yy HH:mm:ss} [%thread] %level %logger - %message%newline"/>
</layout>
</appender>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{ABSOLUTE} [%thread] %level %logger - %message%newline"/>
</layout>
<filter type="log4net.Filter.StringMatchFilter">
<stringToMatch value="test"/>
</filter>
<filter type="log4net.Filter.DenyAllFilter"/>
</appender>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline"/>
</layout>
</log4net>
<appSettings>
<!--<add key="DBpackage" value="TESTMOSH." />-->
<add key="DBpackage" value="PCK_DN_VER1."/>
<add key="AuthTokenExpiry" value="900"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.webServer>
<staticContent>
<remove fileExtension=".woff"/>
<remove fileExtension=".woff2"/>
<mimeMap fileExtension=".woff" mimeType="application/font-woff"/>
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2"/>
</staticContent>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
<remove name="OPTIONSVerbHandler"/>
<remove name="TRACEVerbHandler"/>
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>
</handlers>
</system.webServer>
</configuration>
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
/*SystemDiagnosticsTraceWriter traceWriter = config.EnableSystemDiagnosticsTracing();
traceWriter.IsVerbose = false;
traceWriter.MinimumLevel = TraceLevel.Info;*/
//traceWriter.FormatDateTime(new DateTime().ToUniversalTime());
// Web API configuration and services
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
我首先尝试这样做:
$http.post('/api/Authenticate/', { username: username, password: password })
.success(function (data, status, headers, config) {
$http.defaults.headers.common['Token'] = headers().token;
$http.defaults.headers.common['tokenexpiry'] = headers().tokenexpiry;
$rootScope.globals.currentUser.group = headers().groupname;
$http.defaults.headers.common.Authorization = 'Token ' + headers().token;
callback(data);
})
.error(function (data, status, headers, config) {
callback(status);
});
};
似乎问题不在于我的索引页面正在加载,我不知道为什么我认为问题在那里? :)
无论如何,问题出在 oracle.dataaccess dll 文件上 - 我更仔细地调试了它。
我没有在网上找到解决方案,所以我在这里尝试,我真的不知道问题是什么,但我使用 .NET 4.5 应用程序池(不是经典的) 当它需要到达其中一个控制器时,我总是会收到 404 错误 当它到达全局文件时,我试图打印出来 - 但它似乎甚至没有到达那里。
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net>
<root>
<level value="INFO"/>
<appender-ref ref="RollingFileAppender"/>
<appender-ref ref="ConsoleAppender"/>
</root>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="c:\ApplicationLogs\CenterInterface\mylogfile.txt"/>
<appendToFile value="true"/>
<rollingStyle value="Size"/>
<maxSizeRollBackups value="5"/>
<maximumFileSize value="10MB"/>
<staticLogFileName value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{dd/MM/yy HH:mm:ss} [%thread] %level %logger - %message%newline"/>
</layout>
</appender>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{ABSOLUTE} [%thread] %level %logger - %message%newline"/>
</layout>
<filter type="log4net.Filter.StringMatchFilter">
<stringToMatch value="test"/>
</filter>
<filter type="log4net.Filter.DenyAllFilter"/>
</appender>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline"/>
</layout>
</log4net>
<appSettings>
<!--<add key="DBpackage" value="TESTMOSH." />-->
<add key="DBpackage" value="PCK_DN_VER1."/>
<add key="AuthTokenExpiry" value="900"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.webServer>
<staticContent>
<remove fileExtension=".woff"/>
<remove fileExtension=".woff2"/>
<mimeMap fileExtension=".woff" mimeType="application/font-woff"/>
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2"/>
</staticContent>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
<remove name="OPTIONSVerbHandler"/>
<remove name="TRACEVerbHandler"/>
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>
</handlers>
</system.webServer>
</configuration>
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
/*SystemDiagnosticsTraceWriter traceWriter = config.EnableSystemDiagnosticsTracing();
traceWriter.IsVerbose = false;
traceWriter.MinimumLevel = TraceLevel.Info;*/
//traceWriter.FormatDateTime(new DateTime().ToUniversalTime());
// Web API configuration and services
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
我首先尝试这样做:
$http.post('/api/Authenticate/', { username: username, password: password })
.success(function (data, status, headers, config) {
$http.defaults.headers.common['Token'] = headers().token;
$http.defaults.headers.common['tokenexpiry'] = headers().tokenexpiry;
$rootScope.globals.currentUser.group = headers().groupname;
$http.defaults.headers.common.Authorization = 'Token ' + headers().token;
callback(data);
})
.error(function (data, status, headers, config) {
callback(status);
});
};
似乎问题不在于我的索引页面正在加载,我不知道为什么我认为问题在那里? :) 无论如何,问题出在 oracle.dataaccess dll 文件上 - 我更仔细地调试了它。