Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
this does work :

<asp:menuitem navigateurl="https://localhost:44335/counter" text="RollUp Mappings">

however relative path doesn't work :

<asp:menuitem navigateurl="../../../../BlazorApp1/counter" text="RollUp Mappings">

I have a solution with two projects, webforms app and a blazor server app. For the new
functionality that I will implement I want to try blazor server, Thats why I need to call the blazor server app from a webforms app (4.6.1)

how could I get the relative path for the blazor app?
link will be in webfroms app.

What I have tried:

<asp:MenuItem     NavigateUrl="../../../../BlazorApp1/counter" Text="RollUp Mappings" />
Posted
Updated 4-Sep-20 6:27am
Comments
F-ES Sitecore 4-Sep-20 11:55am    
Not sure that's going to work. The absolute url works as you are making an http call to a different host which is running that blazor site in that host server which supports blazor, and returns html. Using a relative path means accessing a page that is running in the same host as the parent site (webforms) which doesn't support your blazor page. You're effectively trying to run webforms and blazor in the same site which I'm not sure is supported. If it is you haven't configured it properly.
Richard Deeming 4-Sep-20 11:55am    
REPOST
This is the same question you posted yesterday:
How to use ASP:menuitem navigateurl property to call blazorserver app in the same solution?[^]

You cannot use a relative path to navigate from one project to another when you run them from Visual Studio.
bgundas 4-Sep-20 12:18pm    
No sir, its related but not the same question. the other question was about setting muliple startup projects. I got it working with your help.
However now, the problem will arise when I put this code dev server. How will I know where is the blazor app hosted on dev server? Thats why I need to use some sort of relative url so I can still call the blazor app in dev or uat servers.

1 solution

Quote:
How will I know where is the blazor app hosted on dev server?
Put the base URL of the other application in the appSettings section of your web.config file. You can use the application settings expression builder to insert the value into your page:
XML
<appSettings>
    <add key="RollUpMappingsUrl" value="https://localhost:44335/counter" />
</appSettings>
ASPX
<asp:MenuItem NavigateUrl="<%$ AppSettings:RollUpMappingsUrl %>" Text="RollUp Mappings" />
ASP.NET Expressions Overview | Microsoft Docs[^]

When you deploy your application, update the config file to specify the live URL to use.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900