asp.net mvc 4 - How might I get to the SSL URL defined in the properties of an MVC project? -
i have ssl enabled , trying write own requirehttpsattribute
allow easy testing iis express. when redirects, redirects port 44301, don't want hard code this, want read existing configuration.
public sealed class requirehttpsalternativeportattribute : requirehttpsattribute { protected override void handlenonhttpsrequest(authorizationcontext filtercontext) { base.handlenonhttpsrequest(filtercontext); //alter port in base classes result var baseredirect = filtercontext.result redirectresult; if (baseredirect == null) { throw new exception("no redirect suppied base class"); } var builder = new uribuilder(baseredirect.url); var targetport = 44301; //need settings if (builder.port == targetport) return; //already correct port //change port builder.port = targetport; var redirectresult = new redirectresult(builder.tostring()); filtercontext.result = redirectresult; } }
44301 defined in mvc project properties under ssl url. question is, accessible during runtime anywhere?
Comments
Post a Comment