How to navigate in C#? #246

Closed
opened 2026-01-29 16:34:47 +00:00 by claunia · 5 comments
Owner

Originally created by @Symbai on GitHub (Dec 30, 2018).

How can I load a different view within C#? The documentation and all samples only contain javascript code. The file secondView.cshtml is in the same folder as index.cshtml is.

var mainWindow = Electron.WindowManager.BrowserWindows.First();
mainWindow.LoadURL("file://${__dirname}/secondView.html");
Originally created by @Symbai on GitHub (Dec 30, 2018). How can I load a different view within C#? The documentation and all samples only contain javascript code. The file secondView.cshtml is in the same folder as index.cshtml is. ``` var mainWindow = Electron.WindowManager.BrowserWindows.First(); mainWindow.LoadURL("file://${__dirname}/secondView.html"); ```
Author
Owner

@robertmuehsig commented on GitHub (Dec 30, 2018):

You boot up a complete ASP.NET Core Application - so you just can "navigate" via typical links or redirects.
When your mainWindow has an open "index.cshtml" just put a link inside it and point to the secondView.html.
The negative point here is, that this will "re-render" the view (just like in a normal web browser)..

Hope this helps!

@robertmuehsig commented on GitHub (Dec 30, 2018): You boot up a complete ASP.NET Core Application - so you just can "navigate" via typical links or redirects. When your mainWindow has an open "index.cshtml" just put a link inside it and point to the secondView.html. The negative point here is, that this will "re-render" the view (just like in a normal web browser).. Hope this helps!
Author
Owner

@Symbai commented on GitHub (Dec 30, 2018):

But I don't want to navigate within the app via buttons or links. Instead within C# from the controller.

@Symbai commented on GitHub (Dec 30, 2018): But I don't want to navigate within the app via buttons or links. Instead within C# from the controller.
Author
Owner

@robertmuehsig commented on GitHub (Dec 30, 2018):

Well - you could just redirect the browser to the target view. This would be the "normal" behavior. I'm not sure if there are other options available.

@robertmuehsig commented on GitHub (Dec 30, 2018): Well - you could just redirect the browser to the target view. This would be the "normal" behavior. I'm not sure if there are other options available.
Author
Owner

@Symbai commented on GitHub (Dec 31, 2018):

That sounds fine but how would do that? How can I tell the browser to visit secondView.cshtml from C# controller? That's where I'm stuck.

@Symbai commented on GitHub (Dec 31, 2018): That sounds fine but how would do that? How can I tell the browser to visit secondView.cshtml from C# controller? That's where I'm stuck.
Author
Owner

@robertmuehsig commented on GitHub (Dec 31, 2018):

Like this: https://stackoverflow.com/questions/45830460/how-to-redirect-to-a-asp-net-core-razor-page-no-routes

Or just google "ASP.NET Core Redirect"

@robertmuehsig commented on GitHub (Dec 31, 2018): Like this: https://stackoverflow.com/questions/45830460/how-to-redirect-to-a-asp-net-core-razor-page-no-routes Or just google "ASP.NET Core Redirect"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#246