Hi,
Solved the problem by changing code to this.
public ProjectNameConnectionStringResolver(IAbpStartupConfiguration configuration,IAmbientDataContext ambientDataContext)
: base(configuration)
{
_appConfiguration = AppConfigurations.Get(
typeof(ProjectNameConnectionStringResolver).GetAssembly().GetDirectoryPathOrNull(),
Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")
);
_ambientDataContext = ambientDataContext;
}
Thanks @ismcagdas
Hi,
Our subscription has been expired I don't have access to that repo, So I cannot add issue there.
Thank you
IAmbientDataContext
helped me to achive what I need.
Thanks @zony.
Hi,
I managed to override IConnectionStringResolver
successfully and now I can change connection string dynamically but how should I know that this is a read request so I should change connection string to Read Replica database?
I found this solution in one of support tickets. It says:
You can define an attribute (for Get only) and use it the operations you want to use read-only database.
Can you show me how to add attribute to ConnectionStringResolveArgs
for example when calling a get method in any repository? So, in this case I can decide based on that attribute inside my custom IConnectionStringResolver and change connection string.
Hi Zony,
Thanks for answer.
I saw first solution, but it is not good solution for my scenario because In that case I will have all tables and Dbsets and etc.. duplicated and project will turn into mess.
Can you describe second solution a bit more? Is ther any documentation for this. any code sample?
Thanks
Hi,
I tried these steps:
Configure Web.Host\appsettings.Staging.json as you said with same value like this:
{
"ConnectionStrings": {
"Default": "Server=localhost; Database=xxxDb; User=xxx; Password=xxx;"
},
"App": {
"ServerRootAddress": "http://{TENANCY_NAME}.test.sitename.com/",
"ClientRootAddress": "http://{TENANCY_NAME}.test.sitename.com/",
"CorsOrigins": "http://test.sitename.com,http://*.test.sitename.com"
}
}
Run dotnet publish --configuration Staging --output ../../Publish/SiteName /p:EnvironmentName=Staging
Create IIS web site with these bindings test.sitename.com
and *.test.sitename.com
Copied all publish files to IIS site's physical path.
Then tried to visit test.sitename.com, I get this erorr Oops! You're lost. We can not find the page you're looking for.
Then tried to visit test.sitename.com/ui/login it loads api login pages. But i couldn't find a way to load ui.
I Change config like this:
{
"ConnectionStrings": {
"Default": "Server=localhost; Database=xxxDb; User=xxx; Password=xxx;"
},
"App": {
"ServerRootAddress": "http://{TENANCY_NAME}.api.test.sitename.com/",
"ClientRootAddress": "http://{TENANCY_NAME}.test.sitename.com/",
"CorsOrigins": "http://test.sitename.com,http://*.test.sitename.com"
}
}
but result was same.
note: I can get things work with two IIS site one for UI and the other for api. But I think it shoud also work under one site.
Hi @ismcagdas,
tnx
Hi @gterdem
Thanks for clarification.
Hi I didn't get what you mean, can you explain with an example.
I asked for ASP.NET Core and Angular single solution not seprated.