I have a console app that needs to self-host a web site. I have small middle-ware classes that authenticate and log. Every example I find online is usually just sending text or raw html. I need to serve an .aspx page. Response.Redirect
doesn't seem to work. Below is the middleware that might serve the page. Or perhaps I'm approaching this wrong.
using Microsoft.Owin;
using AppFunc = System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>;
namespace MyMiddleware
{
public class MyContentMiddleWare
{
public AppFunc MyContentAppFunc(AppFunc next)
{
AppFunc appFunc = async (IDictionary<string, object> environment) =>
{
IOwinContext context = new OwinContext(environment);
await context.Response.WriteAsync("<h1>SERVE PAGE INSTEAD</h1>");
};
return appFunc;
}
}
}
You can't serve aspx pages from inside Microsoft.Owin, they are tightly coupled to System.Web. What you can do is run Microsoft.Owin in the System.Web pipeline to augment the functionality with things like auth.