I have a very simple problem: Depending on what environment I deploy Identity Server 3, I want to have the logon page to display a different image. The image source location is defined in the web.config
and transformed depending on build configuration.
I'm overriding the partial _login.html
to allow the image to be displayed, but I cannot find out how to (easily) pass into the view a variable that defines this configuration variable.
I believe that this is possible by using a CustomViewService
shown here : http://identityserver.github.io/Documentation/docs/advanced/customizingViews.html But I would like to know whether there is an easier way of passing a variable into a view without having to create a CustomViewService
.
Would it be possible to extend the CommonViewModel
and get Identity Server 3 to resolve this at run time ? The ExtendedCommonViewModel
would be extremely simple :
public class ExtendedCommonViewModel : CommonViewModel
{
public string ImageLocation
{
get { return ConfigurationManager.AppSettings["ImageLocation"].ToString(); }
}
}
And then use it in the _login.html
view as <img src="{ImageLocation}" />
I realise that this would still need to be parsed into the Replace
function in the default view service, and so this is where this idea falls down : https://github.com/IdentityServer/IdentityServer3/blob/master/source/Core/Services/DefaultViewService/DefaultViewService.cs
So to reiterate; Is there an easy way to pass a variable into an overridden partial view in Identity Server 3 without having to create a CustomViewService
?
Edit :
Additional - I can see a hack of a solution by passing the variable in as a Scripts
parameter on the DefaultViewServiceOptions
but this seems too hacky.
Would is be possible to extend the DefaultViewServiceOptions
and add a custom dictionary that can contain custom model parameters that could then be used in the view. This seems like the best solution, but would mean changing the DefaultViewService