Looking for advice on passing user credentials from a view bag (that stores session details when the user logs onto my web app) to the web.config where i have a connection string which i would like to pass the user and password to, as seen below.
Thanks,
You shouldn't do this.
A webconfig shouldn't be changed at runtime depending on the session. remember every user has his/her own session. This means that if there would be multiple users at the same time there could be concurrency problems meaning that for example you can have the username of user1 and the password of user2 in the config.
what you could do is use the following in a view for example:
@Html.MvcReportViewer(string reportPath, string reportServerUrl = null, string username = null, string password = null, IEnumerable> reportParameters = null, ControlSettings controlSettings = null, object htmlAttributes = null, FormMethod method = FormMethod.Get)
where username and password would come from your viewbag.