c# - Website is not taking connection string from web.config. it is searching for app.config -
i have project 3 tier structure dataaccesslayer, businesslogiclayer , website.
in dataaccesslayer have used f# library project connectionstring accessing app.config file
f# code -
type dbschema = sqldataconnection<"","myconnection"> let connectionstring = system.configuration.configurationmanager.connectionstrings. ["myconnection"].connectionstring
app.config code -
<connectionstrings> <add name="myconnection" connectionstring="data source=myserver;initial catalog=mydb;persist security info=true;user id=sa;password=xyz;" providername="system.data.sqlclient"/> </connectionstrings>
now have given reference of dll in website businesslogic , website project.
i calling function of businesslogiclayer data -
var mydatalist = businesslogic.getalldata().tolist();
now issue is, website searching connectionstring in app.config file instead of web.config. want take connectionstring web.config
you can fetch connection string using below line of code -
using system; using system.configuration; var connectionstring=configurationmanager.connectionstrings["myconnectionstring"].connectionstring;
here reference : connection string app.config
Comments
Post a Comment