一些背景知识:我最近将一个Startup.cs文件添加到较旧的.NET 4.5.1 Web.Forms站点,以便允许SSO身份验证。我在同一解决方案中有另一个新项目,它承载SSO代码(IdentityServer3)。我想在本地IIS(IIS 10)而不是IIS express上运行,因此我可以来回切换调试代码。
这里是调用SSO进程的代码。它在page_load中用于测试目的。
protected void Page_Load(object sender, EventArgs e)
{
var authProps = new AuthenticationProperties { };
HttpContext.Current.GetOwinContext().Authentication.Challenge(authProps);
}
客户端的启动代码:
[assembly:OwinStartup(typeof(MyNamespace.Startup))]
namespace MyNamespace
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
var authority = SSOSettings.SSOBaseUrl;
var myUrl = "http://localhost/MyNamespace_WebApp/";
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
AuthenticationType = "oidc",
SignInAsAuthenticationType = "Cookies",
Authority = authority,
ClientId = "myclientid",
RedirectUri = myUrl,
PostLogoutRedirectUri = myUrl + "open/Login.aspx",
ResponseType = "id_token token",
Scope = "openid profile email",
UseTokenLifetime = false
});
}
}
当正在调试Web项目(SSO客户端)时,使用IIS Express或在Visual Studio中将其设置为启动项目并使用IIS进行调试时,它将调用SSO站点并启动SSO流程。但是当我尝试在没有调试的情况下通过IIS运行它时,我收到一个错误:
字符串参数' namespaceName'不能为空或空。
堆栈跟踪似乎表明在尝试运行OWIN启动过程时出现了问题。
[ArgumentException: The string parameter 'namespaceName' cannot be null or empty. Parameter name: namespaceName]
System.Web.UI.TagPrefixAttribute..ctor(String namespaceName, String tagPrefix) +3663848
System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs) +0
System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs) +48
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +846
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +144
Owin.Loader.DefaultLoader.SearchForStartupAttribute(String friendlyName, IList`1 errors, Boolean& conflict) +188
Owin.Loader.DefaultLoader.GetDefaultConfiguration(String friendlyName, IList`1 errors) +68
Owin.Loader.DefaultLoader.LoadImplementation(String startupName, IList`1 errorDetails) +89
Owin.Loader.DefaultLoader.Load(String startupName, IList`1 errorDetails) +30
Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup() +165
(Stack trace truncated, but nothing in the stack trace that hits the site's custom code)
当网站调试IIS时,OwinContext上是否有可能设置不同的内容?
谢谢!