c# - HTTP Header on server side -
c# - HTTP Header on server side -
we have build asp web api. authentication done hmac in authorization header. on server side check hmac code , if valid request proceeds resource. our project construction consist of multiple layers.
-api- -businesslogic-in businesslogic have linq sql connection. connectionstring dynamic , in api layer. best way pass connectionstring businesslogic ? came thought of adding header connectionstring in it. specific header system.web.httpcontext.current.request.headers. works safe ?
you should seek me more clear because question doesn't exclusively makes sense me.
"this connectionstring dynamic , in api layer"
do mean store somewhere in web.config / app.config of web api project?
" best way pass connectionstring businesslogic ?"
do want pass web api project class of "businesslogic" project? advise appsettings of business logic (will inherit 1 of web api project).
configurationmanager.connectionstrings["your_connection_string_name_here"]
i abstract app settings separate class (+ interface) more mockable unit testing.
e.g:
public interface igetappsettings { namevaluecollection getall { get; } string myconnectionstring { get; } } public class myappsettings : igetappsettings { public namevaluecollection getall { { homecoming configurationmanager.appsettings; } } public string myconnectionstring { { var value = configurationmanager.connectionstrings["myconnectionstring"]; homecoming value.tostring(); } } }
c# asp.net web
Comments
Post a Comment