asp.net mvc 3 - MVC 3 Global.asax Redirect request -
i have ssl certificate example.com
domain. want make redirection if user wants enter site www.example.com
. code below works fine, can't enter site if want use https://www.example.com
in url bar. why ?
protected void application_beginrequest(object sender, eventargs e) { if (request.url.host.startswith("www", stringcomparison.invariantcultureignorecase)) { response.clear(); response.addheader("location", string.format("{0}://{1}{2}", request.url.scheme, request.url.host.substring(4), request.url.pathandquery) ); response.statuscode = 301; response.end(); } }
i guess there no binding on web server listening https://www.example.com
. have valid certificate https://example.com
. when attempt request https://www.example.com
iis drops connection.
Comments
Post a Comment