Frage

I'm upgrading from .NET 2.0 to MVC 4. Back in .NET 2.0 webform, we had to inject license information on the fly to the footer of the software by override the "Render" function in .aspx.cs page (using HtmlTextWriter), find a particular spot of the footer and then insert the license text info there.

The reason I don't want to directly put that in the viewstart page or any razor page themselves using HTMLhelper is because I don't want my customers to mess with it. So hard code is not an option.

I use Glimpse and I see Glimpse is enabled by adding a HTTPModule,etc in web.config and magically, an icon appears on my app. Something similar ?

Bottom line is, I need to hijack the finished HTML output, modify it and return the final result to client.

How do you do this in MVC? HttpModule?

Thanks!

War es hilfreich?

Lösung

Glimpse uses a feature of ASP.NET called a ResponseFilter to change the output HTML on the fly.

The ResponseFilter, in the case of Glimpse, is set inside the HttpModule - but it could be set anywhere.

Four Guys From Rolla has an old but still relevant article on how to create ResonseFilters.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top