Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"The Application Url cannot contain a query string or fragment" error in asp.net core

In my ASP.NET Core 3.1 application, I need to set the query string parameter right from the launch of the application. But when I set an applicationUrl having query string parameter in launchsettings.json file, application fails to start.

You can see that, the application URL box is turned yellow and Visual Studio does not allow me to save !

enter image description here

If I open the launchsettings.json in the text editor, set this URL and save the file, I get following error while running the application from Visual Studio. I get the following error:

enter image description here

Can someone explain, 1. Why it's not possible? 2. What's the solution? 3. What's ASP.NET Core's way of passing some values during start of the session?

Note: I need to pass TPAId while launching the application because my app is one of the many other enterprise applications and that's somehow forcing me to do this.

like image 753
Learner Avatar asked Sep 20 '25 17:09

Learner


1 Answers

In your launchSettings.json file, under your Profiles, you can add a launchUrl property.

"IIS Express": {
    "commandName": "IISExpress",
    "launchBrowser": true,
    "launchUrl": "?TPAId=876894",
    "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
    }
}
like image 165
Terry Avatar answered Sep 22 '25 10:09

Terry