This is (one way) of getting the base URL for a remote API from Blazor #11044
-
I needed to explicitly set the URL to an API because I'm using this upload components from Syncfusion that has a savUrl parameter that needs to be set with full url. To do this you can inject the following into YourPage.razor.cs page (if you are at least using Dynamic client proxies) private readonly AbpRemoteServiceOptions abpRemoteServiceOptions;
public YourPage(IOptions<AbpRemoteServiceOptions> abpRemoteServiceOptions)
{
this.abpRemoteServiceOptions = abpRemoteServiceOptions.Value;
} and then in your code you can access the values var remoteServiceConfig = abpRemoteServiceOptions.RemoteServices.GetConfigurationOrDefault("Default"); //or "BookStore"
var url = remoteServiceConfig .BaseUrl; Is this the best way? Is it the only way? I don't know! I couldn't find any mention in the Issues,Discussions or in the support forum that could help me.. maybe there is something there but its not easily found.. I got to this conclusion after trying out I just wanted to share this code because this is the stuff I find most frustrating with the abp.io documentation. These "corner" cases that I have to spend long time on each time I go out of the beaten path. Don´t get me wrong... I like apb.io but the documentation for lots of basic stuff just isn´t that good (even though there is a lot of things in there) How to make the documentation better?I suggest that we could add comments on each documentation page (just like Microsoft docks have) where users can comment and contribute their issues and solutions. You can then decide to augment the docs. But yes hopefully this will help somebody down the line... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi @sturlath, I think it's the most suitable way.
Configure<AbpRemoteServiceOptions>(options =>
{
options.RemoteServices["MyRemoteServiceName"] = new RemoteServiceConfiguration
{
BaseUrl = "...."
};
});
Thanks for your suggestion. We've added something similar to our document platform, you can give your feedback by using it.
|
Beta Was this translation helpful? Give feedback.
Hi @sturlath, I think it's the most suitable way.
AbpRemoteServiceOptions
sets automatically but you can also configure it, you can read the relevant section from Dynamic C# API Client Proxies documentation.