Hi @lesponce ,
Welcome to Microsoft Q&A forum.
I get this error: The path in 'value must start with '/' (Parameter 'value')"
For this issue, please check the Branch the middleware pipeline:
When Map is used, the matched path segments are removed from HttpRequest.Path and appended to HttpRequest.PathBase for each request. you can refer to the following sample code:
private static void HandleMapTest1(IApplicationBuilder app)
{
app.Run(async context =>
{
await context.Response.WriteAsync("Map Test 1");
});
}
private static void HandleMapTest2(IApplicationBuilder app)
{
app.Run(async context =>
{
await context.Response.WriteAsync("Map Test 2");
});
}
public void Configure(IApplicationBuilder app)
{
app.Map("/map1", HandleMapTest1);
app.Map("/map2", HandleMapTest2);
app.Run(async context =>
{
await context.Response.WriteAsync("Hello from non-Map delegate. <p>");
});
}
As we can see in the Map method, the PathString should start with '/'. So, if you want to use the Map method, you have to change the path string to start with '/'.
In the appsettings.json file, the value of CorpName should start with /
, like this:
"CorpName": "/https://mydomain.com",
You could check the following screenshot:
Besides, from your code and description, you might want to get the request url and do something, right? If that is the case, you could consider using the MapWhen method, then, you can get the request url from the HttpContext. refer to the following code:
private static void HandleBranch(IApplicationBuilder app)
{
app.Run(async context =>
{
var branchVer = context.Request.Query["branch"];
await context.Response.WriteAsync($"Branch used = {branchVer}");
});
}
public void Configure(IApplicationBuilder app)
{
app.MapWhen(context => context.Request.Query.ContainsKey("branch"),
HandleBranch);
app.Run(async context =>
{
await context.Response.WriteAsync("Hello from non-Map delegate. <p>");
});
}
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion