I have an ASP.NET core REST API service with .net core 3.1 version. I want to create a common variable in appsettings.json or other config files for a particular part of the URL of API. For example, if my URL is like this http://localhost:31660/Inventory/v1.0/{Id}/data here the/Inventory/v1.0 will be common for every request coming to methods of this controller. Currently, it is set in the controller. Is there any way to put that part in the config file once and get that variable whenever required to set it?
How to assign base path of API URL in config file?
1.9k Views Asked by Hope At
1
There are 1 best solutions below
Related Questions in ASP.NET-CORE
- ASP.NET 5 Class Library - Nuget package Web.Config transform
- Asp.Net 5 correct way to access logging config file from Startup.cs
- What is the difference between 'dependencies' and 'frameworkAssemblies' in project.json?
- Getting absolute URLs using ASP.NET Core
- How to add Project Reference in asp.net 5 application
- Configure the authorization server endpoint
- Observer for fire&forget Task
- IApplicationBuilder exists in both Microsoft.AspNet.Http.Abstractions and Microsoft.AspNet.Http
- What frameworks are available in ASP.NET Core (ASP.NET 5) applications?
- How do I include 'System.Runtime.Serialization.Json' namespace in my VSCode project on Mac OS X?
- How to suppress warnings when building an ASP.NET 5 project?
- Dependency Injection in asp.net 5 custom classes, what is the correct way?
- How to access IConfiguration property from Controller in ASP.NET 5
- Getting a scoped component from a IDocumentStoreListener
- How is execution passed from the clr to Startup class (startup.cs)?
Related Questions in URL-ROUTING
- How to add menus/ subtopics for meteor site?
- Why has overriding password hashing caused urls to break in magento admin?
- How to make morre readable URIs using unique-id-plus-redundant-information (UPRI) using PHP with Laravel
- htaccess set http on all pages except login page
- Flask URL routing : url_for only passes first argument
- Routing in Express.js
- Redirect website to another website if blocked in particular region
- $location error in angularJS
- Ember.js Routing: 'refreshModel: true' on queryParams without updating child route model
- passing parameters to dynamic templateurl
- Node.js / Express routing doesn't work properly
- ASP .NET Routing with Web Forms
- Express dynamic routing using / and /:slug as different route files
- Open page url in modal on a page (Facebook Photo URLs)
- Including controller when routing in AngularJS
Related Questions in REST
- Spring RestTemplate passing the type of the response
- .net rest service with JSON string and consumed with java client
- SuiteCRM how to retrieve all account related contacts
- http status code for failed email send
- cloud foundry - 413 Request Entity Too Large
- Why does PHP add "\r\n" to an empty string?
- WCF Service not accepting multiple body parameters
- How to send Rest GET request that contains "#" value in url parameters?
- Phalcon PHP - RESTful API
- Object of class CS_REST_Wrapper_Result could not be converted to string in CAMPAIGN MONITOR
- purchase individual items and subscriptions in the same PayPal REST API transaction
- Empty Response Received on Android POST Request
- angular load more tweets onclick
- Async vs Horizontal scaling
- Responding to an Office 365 event invite via REST
Related Questions in CONFIGURATION-FILES
- Group nodes in hiera by hiera-defined fact
- Tree configuration to turn on/off the features in java
- do I need to restart ALL the hadoop daemons whenever I make changes to xml configuration files
- mongod config file production
- fileio disable Rserve
- OSX tmux configuration session open file in vim automatically
- Writing to .config files
- Python root logger messages not being logged via handler configured with fileConfig
- Solution with different project and shared configSections
- Is there a way to export all the Visual Studio Macro variables
- CQ5 author. hyperlinks are getting shortened
- Cppcheck GUI: Excluding a file or folder from checking
- configparser: parsing error with omitted values
- How to define a map in Hazelcast
- How to use %exclude macro properly in rpmbuild SPEC files?
Related Questions in BASE-PATH
- How do I use basePath() in a view rendered out of a library?
- Spring data rest disable CORS on base-path
- How to assign base path of API URL in config file?
- Changing URL of default image upload location in CodeIgniter
- How to add dynamic path to the single-spa-router path attribute in single spa react application
- zend framework basepath
- Getting base directory in CakePHP
- Multiple API Gateways from different regions with the same Custom Name and different base path
- Getting the base path/URL
- Can't reach backend when url base is set
- MODX Revo, Path Issue with friendly URLS (only in IE)
- How can I set webpack public path on each server request?
- jekyll BASE_PATH doesn't work
- Extra slash in redirect_uri
- Redis bitnami Helm Chart FAILED statefulset.yaml nil pointer evaluating interface {}.BasePath
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
According to your description, I suggest you could consider using custom route attribute to achieve your requirement.
You could create a static class to read the appsettings and then pass the
{Id}/dataas parameter to the custom route attribute class to achieve your requirement.More details, you could refer to below codes:
appsettings.Development.json:
MyApiControllerAttribute class:
Usage:
Result: