httpmodule

Why RewritePath changes the Browser Url?

走远了吗. 提交于 2019-12-11 02:32:50
问题 I have an ASP.NET 4 HttpModule (see code below). When the url path starts with "/1.0" I want Cassini/IIS to go to MyService.svc. However, I don't want to show "MyService.svc" to the user (i.e. no update to the url in the browser). I want the user to see "www.something.com/1.0". I was pretty sure that RewriteUrl isn't supposed to change the browser url, but in my case it does. Any idea why? public void Init(HttpApplication context) { context.BeginRequest += delegate { HttpContext ctx =

Porting HttpModule .Net Class Library to .Net Core Web API

左心房为你撑大大i 提交于 2019-12-11 02:25:53
问题 I am migrating a project from .net Web Application to .Net core Web API. I am using HTTP Module which is .net framework class library, in IIS Integrated mode. So, thought to port as it is, to my new core app. I pasted web.config to my new core app and added a project reference to that Http Module and it started working. I am having some Context.Response.Write in my BeginRequest method, and I can see those lines whenever I am making a call to my web api. But, I am having some questions here.

Programmatically change locale (language) of a page

只谈情不闲聊 提交于 2019-12-10 23:15:45
问题 I have two root nodes in my Umbraco website.. one is set to English and other is set to German using Manage Hostnames .. |- en |---- english page1 |---- english page2 |- de |---- german page1 |---- german page2 http://mywebsite.com is set to en node and http://mywebsite.de is set to de node. I need to change the German node's language to English in certain conditions.. Is this possible and how? For example if someone calls an English page using German hostname, I need to change the locale to

ASP.NET MVC5 application throwing NullReferenceException when authorizing

雨燕双飞 提交于 2019-12-10 17:16:46
问题 I have an MVC5 application that is throwing a NullReferenceException on the production server when using the [Authorize] attribute on a controller. The application is using forms authentication. The production server is Server 2008 SP 2 (.NET 4.5.1 and IIS 7). The start of the stack trace is: [NullReferenceException: Object reference not set to an instance of an object.] System.Web.Mvc.AuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext) +38 System.Web.Mvc.AuthorizeAttribute

Custom IIS module conflicting with gzip

。_饼干妹妹 提交于 2019-12-10 11:28:28
问题 As an experiment I’ve been toying with an idea of creating an IIS managed module to modify CSS files on fly. The backstory is that all out web applications keep a shared and common version number which we append to each JS, CSS and image reference (in HTML) and I wanted to modify the actual content of the CSS to also append the version number to image references in CSS. So, for instance: span.warning { background-image: url(warning-icon.png) } should become: span.warning { background-image:

Redirect all naked domain urls to subdomain(www) urls preserving the url, except for one page on IIS/ASP.NET

依然范特西╮ 提交于 2019-12-10 09:24:38
问题 Whats the best way to achieve the above? I do know that it can be achieved at HttpModule level. Is it possible just via web.config(easier and faster to code execute). 回答1: It's easy to do this with the URL rewrite module through the web.config : <rewrite> <rules> <clear /> <rule name="Redirect naked domains to www.domain.com" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll"> <add input="{HTTP_HOST}" negate="true" pattern="^www\." /> <add input="{REQUEST_URI}"

OAuth 2.0 authentication in HTTP Module

删除回忆录丶 提交于 2019-12-10 03:49:07
问题 Is it possible to implement OAuth(Open Authorization) 2.0 or 1.0 in HTTP Module. Why i m choosing this because, each and every request will first reaches the HTTP Module, so from that request i have to authenticate Is it possible ? If YES means , please like a related link for that Help me.. 回答1: Yes, this is possible. In fact mod_auth_openidc does exactly that for Apache (and for OpenId Connect, which is a protocol built on OAuth2). More on the scenario here: https://auth0.com/blog/2014/08

How to inject HTML before closing html tag in a HTTPModule

二次信任 提交于 2019-12-09 23:57:45
问题 I'm trying to inject some additional markup in the response but its not outputting as expected. For example the following code will output: ... </html>CONTENT private void OnEndRequest(Object source, EventArgs e) { HttpApplication application = (HttpApplication)source; HttpContext context = application.Context; context.Response.Write("CONTENT"); } But i want the content to output right before the closing html tag ... CONTENT</html> Any ideas on how to achieve this? 回答1: You should use an

Detecting if a HttpModule is loaded

℡╲_俬逩灬. 提交于 2019-12-09 16:04:17
问题 I'm trying to find a way to programmatically check if a particular HttpModule is loaded (as a component I'm writing requires the module to work correctly). I'm trying: bool ismodulepresent = false; foreach(HttpModuleAction module in ((HttpModulesSection)ConfigurationManager.GetSection("system.web/httpModules")).Modules) { if(module.Type == typeof(MyModule).FullName) { ismodulepresent = true; break; } } But that only works for the IIS5.1 <httpModules> section and not the newer <system

Custom HttpModule for IIS 7 for integrated

十年热恋 提交于 2019-12-09 11:45:29
问题 I'm having troubles with a custom Error handler I built. It should be a HttpModule , but when I add it to my web.config 's system.webServer/modules tag, it is not initiated. This is my web.config section: <system.webServer> <modules> <add name="AspExceptionHandler" type="Company.Exceptions.AspExceptionHandler, Company.Exceptions" preCondition="managedHandler" /> </modules> </system.webServer> This is the code in my HttpModule : using System; using System.Web; using Company.Settings; using