locked
Need to access the config file key from cshtml page. RRS feed

  • Question

  • Hi,

    I need to access the key from config file and concatenate that with my css script.

    Could you please help me how to do it.

    Ex:

    config file <add key="Version" value="1.0" />

    how to access it with mvc application views shared folder mail cshtml

    <link rel="stylesheet" type="text/css" href="~/Content/styles.css?V=???">

    Regards,

    Sunil

    • Moved by CoolDadTx Monday, May 4, 2020 3:17 PM ASP.NET related
    Monday, May 4, 2020 3:38 AM

All replies

  • You  would most likely have to use jQuery or JavaScript to execute Ajax to access a MVC controller action method to go read the config file and return the results.

    This can be discussed at the MVC forum in ASP.NET forums.

    http://forums.asp.net/

    Monday, May 4, 2020 7:30 AM
  • Please post questions related to MVC in the ASP.NET forums.

    They can tell you have to use Razor to load your config file setting from the config via server side code. Since you're using a server-side path for the link Razor will let you inject the value on the server side before sending to the client.


    Michael Taylor http://www.michaeltaylorp3.net

    Monday, May 4, 2020 3:17 PM