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
- Windows environment variables at appsettings.json
- Which approach is right while creating a service for your update method?
- New Blazor Web App, Password Reset "A valid antiforgery token was not provided"
- No webpage was found for the web address: https://localhost:7002/Category/Add?area=Admin. Why is my URL generated like ?area=Admin instead of /Admin/
- how to get the html for a tag helper in code
- How to share authorization implemented in the server project with the client project in Blazor Web App Auto project?
- Why https is disabled on publish in .NET Core 7.0
- How to set language in a server-side rendering blazor app
- How can I debug server side rendering blazor code in a component?
- ASP.NET Core 6 randomly returning 200 with empty response
- ASP.NET Core MVC : NullReferenceException: Object reference not set to an instance of an object
- ASP.NET Core Identity Custom Register Endpoint
- VS Community 2022 cannot install dotnet-ef when i try to publish
- How does ASP.NET Core Identity ensure username is unique under concurrent conditions?
- In clean architecture, is the presentation layer allowed to communicate directly with the infrastructure layer?
Related Questions in URL-ROUTING
- How to automatically change path in angular when scrolling
- Vue 3 router changing <routing-view/> but not URL
- Troubleshooting Node.js Express Server Routing Issue
- How to configure .htaccess file for two different websites routing in my shared hosting server
- How do I assign a subdomain.domain.com, domain.com and domain.com/[path] to three different Next JS projects
- Two apps on same domain share resources when window.open(url, "_blank")
- React Routing in web development using an index template
- Navigating to a link that is not part of the Django application is throwing a 404 error
- gb_events working routing configuration typo3
- How to dynamically create FastAPI routes/handlers for a list of Pydantic models?
- Dynamic routing in Vue MPA
- By default, Nextjs route is case sensitive. Is there any way we can make it case insensitive?
- Subscribing to Activate Route Paramaters having no effect on ngClaas
- Angular 8.3 - Child not rendered, instead parent is being rendered
- how to Map multiple .net core controller routes
Related Questions in REST
- Query parameter works fine with fastapi application when tested locally but not working when the FastAPI application is deployed on AWS lambda
- Add an http GET/POST entry point to a Django with channels websocket
- Difficulty creating a data pipeline with Fabric Datafactory using REST
- Flutter connection to a local api
- Accessing REST API Status Codes using Azure Data Factory Copy Activity (or similar)?
- Mass Resource deletion in REST
- why when I check endpoint /tasks, an error always appears "error : invalid token" even though I have entered the appropriate token that I got
- How to prevent users from creating custom client apps?
- How to create a REST API with .NET Framework?
- Efficiently Handling Large Number of API Calls with Delphi 10.4 and OmniThreadLibrary
- Put Request throwing 401 [no body] Unauthorized
- Converting img src data to octet-stream
- Implementing Email Verification and Notification System in a Full-Stack Application with React Frontend and Node Backend
- Micronaut - Add Controller from external library
- Moving Template or OVA to Datastore using vCenter API
Related Questions in CONFIGURATION-FILES
- I cant run files because "Java file outside of source root Intellij"
- Context.xml dont set environmet value
- How can I have a variable command name to be interpreted and executed in shell configuration file?
- Change custom parameter in yaml for specific workflow
- Why do k3s nodes need the registry's certificate private key file
- How to use NSISXML to modify a existing config file upon successful installation
- Automatic update of containers on ECS with configuration change
- GridDB Error CM_NOT_SUPPORTED - How to Check and Set Specified Index Type for a Column?
- Unable to access new File("webapp/WEB-INF/classes/hibernate.cfg.xml") in a servlet environment
- Internationalization is not working for spring reactive that is also when using flatmap which is asynchronous
- SpringBoot service application port 1433 problem with external datasource config values
- How to collect data from one host osquery agent to cenral server?
- Store config for individual ConfigurationElement in external .NET config file
- Dll Config not being recognized
- how can I make readthedocs find my configuration file which is already in GitHub project repository root directory?
Related Questions in BASE-PATH
- How to add dynamic path to the single-spa-router path attribute in single spa react application
- using NextAuth with my NextJS app I have error when I switch my app from the standard localhost root to a basePath
- Next.js basepath not taking effect
- How to use subdomain routing when a base path is present (and with base path appended only to specific routes)?
- aws api gateway adding basePath using openApi 3.0.3
- Redis bitnami Helm Chart FAILED statefulset.yaml nil pointer evaluating interface {}.BasePath
- How to prevent CDK from creating default base path mapping for new DomainName
- How to assign base path of API URL in config file?
- Spring data rest disable CORS on base-path
- Multiple API Gateways from different regions with the same Custom Name and different base path
- Angular 2+ - Dynamically change base path of app
- How can I set webpack public path on each server request?
- Extra slash in redirect_uri
- What role does BASE_PATH play in Angular projects?
- JS - Set Base-Path before loading other resources
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 # Hahtags
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: