what is the purpose of defining the URL as a key in the web.config file and get it as a variable in the WebAPI? Why can't we use directly the URL in my WebAPI? what are the differences between both of them?
If you make it as hard coded string in your controller actions, every time when you want to change URL, you might need to update it one by one. But if you store that value in your config file rather than as a hard coded string in your code, which will be
much easier to change that value.
With Regards,
Fei Han
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
1 Points
1 Post
Purpose of accessing the URL from the web config
Jan 18, 2018 03:09 AM|yaduska|LINK
what is the purpose of defining the URL as a key in the web.config file and get it as a variable in the WebAPI? Why can't we use directly the URL in my WebAPI? what are the differences between both of them?
All-Star
40535 Points
6233 Posts
Microsoft
Re: Purpose of accessing the URL from the web config
Jan 18, 2018 08:22 AM|Fei Han - MSFT|LINK
Hi yaduska,
If you make it as hard coded string in your controller actions, every time when you want to change URL, you might need to update it one by one. But if you store that value in your config file rather than as a hard coded string in your code, which will be much easier to change that value.
With Regards,
Fei Han