2

我在 mvc 4.5 之上构建了一个经典的 asp 应用程序,我试图拦截对经典 asp 页面的调用,看起来我无法做到这一点。关于如何的任何想法。不知道如何让中间件拦截这些请求。看起来像这样Can't find method app.UseStaticFiles()类似,但他们使用的是模块。我希望能够使用中间件。

有什么想法吗 ?

添加startup.cs

    using System;
    using System.Threading.Tasks;
    using Microsoft.Owin;
    using Owin;
    using System.Web;
    using System.IO;
    using Microsoft.Owin.Extensions;
    using Microsoft.Owin.Security.Cookies;
    using Microsoft.Owin.Security.WsFederation;
    using Microsoft.Owin.Security;
    using Microsoft.IdentityModel;
    using System.Web.Helpers;
    using System.Security.Claims;
    using System.Collections.Generic;
    using System.Security.Principal;
    using System.Threading;
    using System.Web.Mvc;

    public void Configuration(IAppBuilder app)
    {
        // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
        ConfigureAuth(app);

    }

    private void ConfigureAuth(IAppBuilder app)
    {
        app.Use(typeof(LogMiddleware));
        app.UseCookieAuthentication(new CookieAuthenticationOptions()
        {

            CookieSecure = CookieSecureOption.Always,
            LoginPath = new PathString("/Account/Login"),
            ExpireTimeSpan = TimeSpan.FromMinutes(30),
            CookieDomain = MvcApplication.CookieDomian,
            CookiePath = MvcApplication.ApplicationPath,
            CookieName = "asp.net",
            CookieHttpOnly = true,
            AuthenticationMode = AuthenticationMode.Active,
        }
        });



        app.UseStageMarker(PipelineStage.Authenticate);

        app.MapWhen(
            context => context.Request.Path.ToString().EndsWith(".asp"),
            appBranch =>
            {
                System.Diagnostics.Debugger.Break();
            });
        app.Use(typeof(ResponseHeaderMiddleware));
4

1 回答 1

0

runallmanagedmodulesforallrequests 在 Web 配置中设置为 false。

将此设置为 true 并且它可以工作......谁会猜到。

于 2017-05-11T01:52:58.007 回答