Recent Discussions
- 18KViews1like27Comments
Convert the standard Blazor navigation menu to a collapsible icon menu
While I admittedly love Blazor I’ve always changed the out-of-the-box navigation menu that comes with it. It’s the first manoeuvre I pull when spinning up a new Blazor app, stripping out the purple gradient and getting it in, what I consider, a “blank slate state”. The other change I’ve wanted to make to the out-the-box look is one of those deluxe collapsible menus that leave just the icons showing. Anyone that’s used Azure DevOps will know what I’m talking about. I’ve included a picture to show DevOps example of what I’d like to see in my Blazor app. It gives a load of extra screen real estate which is always a priority for me in business applications particularly with complex or intensive workflows. Plus it gives the user the option to remove the text prompts once they are familiar with the system which is supported with carefully selected icon choices. As with most tasks that I assume will be an obvious solution I hit my search engine of choice and looked to avoid reinventing the wheel. However I found no source of pre-written changes to achieve this and was directed to fairly expensive third party controls to solve this one for me, which, being tight fisted, pushed me to do it for myself. Here I hope you save you the trouble of paying a pretty penny or having to wrestle the CSS into submission and provide a guide for producing a nice collapsible icon navigation menu by altering the existing out of the box menu in Blazor. In the following example I have left all the standard styling as is with the menu and just done the changes required to make the collapsible menu. The three files that require changes are MainLayout.razor, NavMenu.razor and NavMenu.razor.css. The code changes are shown below: Firstly the NavMenu.razor requires a bool value (IconMenuActive) to indicate whether the icon menu is showing or not, then wrap the text of the each NavItem in an if statement dependent on this bool. Then a method for toggling this bool and EventCalBack to send a bool to the MainLayout.razor for shrinking the width of the sidebar. Lastly there needs to be the control for switching menu views (I used the standard io icon arrows). NavMenu.razor <div class="top-row ps-3 navbar navbar-dark"> <div class="container-fluid"> <span class="oi oi-monitor" style="color:white;" aria-hidden="true"></span> @if (!@IconMenuActive) { <a class="navbar-brand" href="">The Menu Title Here</a> } <button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu"> <span class="navbar-toggler-icon"></span> </button> </div> </div> <div class="@NavMenuCssClass" @onclick="ToggleNavMenu"> <nav class="flex-column"> <div class="nav-item px-3"> <NavLink class="nav-link" href="" Match="NavLinkMatch.All"> <span class="oi oi-home" aria-hidden="true"></span> @if (!@IconMenuActive) { <label>Home</label> } </NavLink> </div> <div class="nav-item px-3"> <NavLink class="nav-link" href="counter"> <span class="oi oi-plus" aria-hidden="true"></span> @if (!@IconMenuActive) { <label>Counter</label> } </NavLink> </div> <div class="nav-item px-3"> <NavLink class="nav-link" href="fetchdata"> <span class="oi oi-list-rich" aria-hidden="true"></span> @if (!@IconMenuActive) { <label>Fetch data</label> } </NavLink> </div> </nav> </div> <div class="bottom-row"> <div class="icon-menu-arrow"> @if (!@IconMenuActive) { <span class="oi oi-arrow-left" style="color: white;" @onclick="ToggleIconMenu"></span> } else { <span class="oi oi-arrow-right" style="color: white;" @onclick="ToggleIconMenu"></span> } </div> </div> @code { //bool to send to MainLayout for shrinking sidebar and showing/hide menu text private bool IconMenuActive { get; set; } = false; //EventCallback for sending bool to MainLayout [Parameter] public EventCallback<bool> ShowIconMenu { get; set; } private bool collapseNavMenu = true; private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; private void ToggleNavMenu() { collapseNavMenu = !collapseNavMenu; } //Method to toggle IconMenuActive bool and send bool via EventCallback private async Task ToggleIconMenu() { IconMenuActive = !IconMenuActive; await ShowIconMenu.InvokeAsync(IconMenuActive); } } Next I add in a bit of CSS in to NavMenu.razor.css to put the arrow for toggling the menu at the bottom of the sidebar and a media query to make sure it doesn't show up in mobile view. The CSS classes added are .bottom-row and .icon-menu-arrow. NavMenu.razor.css .navbar-toggler { background-color: rgba(255, 255, 255, 0.1); } .top-row { height: 3.5rem; background-color: rgba(0,0,0,0.4); } .bottom-row { position: absolute; bottom: 0; padding-bottom: 10px; text-align: right; width: 100%; padding-right: 28px; } .icon-menu-arrow { text-align: right; } .navbar-brand { font-size: 1.1rem; } .oi { width: 2rem; font-size: 1.1rem; vertical-align: text-top; top: -2px; } .nav-item { font-size: 0.9rem; padding-bottom: 0.5rem; } .nav-item:first-of-type { padding-top: 1rem; } .nav-item:last-of-type { padding-bottom: 1rem; } .nav-item ::deep a { color: #d7d7d7; border-radius: 4px; height: 3rem; display: flex; align-items: center; line-height: 3rem; } .nav-item ::deep a.active { background-color: rgba(255,255,255,0.25); color: white; } .nav-item ::deep a:hover { background-color: rgba(255,255,255,0.1); color: white; } @media (min-width: 641px) { .navbar-toggler { display: none; } .collapse { /* Never collapse the sidebar for wide screens */ display: block; } } @media (max-width: 640px) { .bottom-row { display: block; } } Finally I add in the handler for the EventCallback to MainLayout.razor and a method to alter the width of the sidebar. MainLayout.razor @inherits LayoutComponentBase <div class="page"> <div class="sidebar" style="@IconMenuCssClass"> <NavMenu ShowIconMenu="ToggleIconMenu"/> </div> <main> <div class="top-row px-4"> <a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a> </div> <article class="content px-4"> @Body </article> </main> </div> @code{ private bool _iconMenuActive { get; set; } private string? IconMenuCssClass => _iconMenuActive ? "width: 80px;" : null; protected void ToggleIconMenu(bool iconMenuActive) { _iconMenuActive = iconMenuActive; } } The final product of these little changes are shown in the pictures below: I'd love to hear if anyone has tackled this in a different way to me and if they've got any ideas on making it cleaner. Have yourselves a wonderful day, Gav71KViews10likes16CommentsHow do create a matrix formula to calculate in all range (B:F) with this rare condition.
Bom dia família, Preciso criar uma fórmula matricial para calcular quantas vezes essa coincidência aparece em todo o intervalo B:F , de acordo com essas condições ( A) na primeira linha ), ( M) na segunda linha ). Tentei com essas 2 fórmulas, mas conta apenas uma coincidência. Alguém tem alguma sugestão por favor? Desde já, obrigado.Solved5.8KViews0likes10CommentsCommon Reasons A C# Program Won't Run On A Clean Install Of Windows 11
So, back in 2017, someone made a C# program to help auto populate a Word Document with data from a design program. And has worked as expected. The few users that use it are on "Upgraded Windows 11" machines and one on Windows 10. If we create a new Windows 11 machine and try to run this program, it doesn't kick off. I made sure that the old PC and the new one had the same .NET as set in ADD WINDOWS FEATURES. It doesn't return an error or generate a system log. It just won't work... I am not a C# developer but I do have the source code...I tried debugging on my machine (where it will not run) and still haven't found a reason why it isn't running. It is almost a needle in a haystack but we need it resolved. Any suggestions?761Views0likes9CommentsDotnet tool install 401 Unauthorized
I'm trying to install the "dotnet-reportgenerator-globaltool" tool via .Net Core custom task. Custom Command: tool Arguments: install --global dotnet-reportgenerator-globaltool --version 4.0,15 Problem: When executing from a directory that contains a nuget.config pointing to a private azure artifacts, I get an error like the following. I don't want to use my feed or need to, but because the nuget.config exists I have no choice. Is there a way I can pass credentials to this command? There is no directory that doesn't inherit the nuget.config [command]"C:\Program Files\dotnet\dotnet.exe" tool install --global dotnet-reportgenerator-globaltool --version 4.0.15 C:\Program Files\dotnet\sdk\2.2.104\NuGet.targets(114,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/bstglobal/_packaging/BSTWEB/nuget/v3/index.json. [C:\Users\VssAdministrator\AppData\Local\Temp\rkrgqk3i.dkp\restore.csproj] C:\Program Files\dotnet\sdk\2.2.104\NuGet.targets(114,5): error : Response status code does not indicate success: 401 (Unauthorized). [C:\Users\VssAdministrator\AppData\Local\Temp\rkrgqk3i.dkp\restore.csproj] The tool package could not be restored.36KViews0likes9CommentsLooking for recommendations for hosting ASP.NET web apps
I've been with an ASP.NET web hosting service for several years. However, the service provided has declined in the last couple of years. So, I started looking for a new, inexpensive, web hosting service. This is for my side business, which doesn't attract that much traffic. Yes, I'm sure that Azure would do, but like I said I'm trying to keep costs down. Naturally, I started searching. I've come across a couple of "Top 10 hosting services for 2023". I've spent about three weeks looking at different ones. I want to publish my ASP.NET Core both from Visual Studio and Azure DevOps Services, using the Azure DevOps FTP task if necessary. My website is currently written in .NET 6. This search experience has not been a pleasant experience. Some services I've spoken to said that because I am working with ASP.NET, then it can only run on Windows, and therefore I couldn't use their service, since they are a Linux only provider (mostly WordPress). I have told two of these web hosting services that ASP.NET Core can run on Linux. I even shared links from Microsoft that ASP.NET Core can run on Linux, Mac, and Windows. In both cases their response was disbelief and a refusal to discuss the topic further with me. Since it seems that many web hosting services have a mindset that refuse to accept the idea that anything from Microsoft can run on Linux, I decided to go back to researching web hosting companies that offer ASP.NET on Windows (both traditional .NET Framework varieties as well as .NET Core with .NET 5, 6, and 7). I settled on one, but they insist that I must allow them to re-register the domain I've owned for 10+ years. They will not allow me to upload my website to them until I've unlocked my website from the domain registrar I use. I've told them, at least three times, that I am satisfied with the domain registrar I have and only need a web hosting provider. They won't hear of it and refuse to go any further with me. So, once again I'm back to searching for a web hosting company for small businesses, that is inexpensive (OK, cheap), that I might be able to have multiple domains on. Therefore, I'd appreciate recommendations from this community, please.1.3KViews0likes8CommentsVersioning my Maui Android App
Previously the way to define version code for Android in Maui .csproj file was like this: <!-- Versions --> <ApplicationVersion>3.1.2</ApplicationVersion> <AndroidVersionCode>3</AndroidVersionCode> With the new release of Visual Studio Preview, this has changed to: <ApplicationVersion>3</ApplicationVersion> It works, from Visual Studio, I can bundle a new .aab package (see image below). We see the version code is defined to 3. Unfortunately the version is defined to 1.0.0 and I don't know how to change this. ...when imported on the Google Play Console, it look like this: Unfortunately, when imported I only see the versionCode 3 (which is defined in the .csproj file as ApplicationVersion). What about the versionName (in parentheses) ? Nothing is planned in the .csproj file ? When imported on the Google Play Console, I don't want to have 3 (1.0.0) but I want 3 (3.1.2)... https://developer.android.com/studio/publish/versioning versionCode — A positive integer used as an internal version number. versionName — A string used as the version number shown to users.26KViews0likes8CommentsExample code for Maui Shell
I am using the transition from Xamarin forms to Maui as an excuse to start using Shell as well. Since Shell has been in the Maui previews for a long time now, I thought it would be easy to get started. But the template does not have Shell as an option, and for some reason I haven't been able to find an example project despite extensive search. Can anyone point me to a simple example of a Maui Shell 'Hello World' app?Solved15KViews0likes8CommentsHow do I convert the C# .dll file to .so file
Requirements: I wrote a standalone module (a separate dll file) in C#, mainly through COM real-time monitoring of a hardware, based on Win7 system. Originally to WPF program call, now Android system app also call this dll file. The application scenario is that a hardware device is connected to an Android tablet, on which an app will call my library files to monitor the hardware. There is no network. The plan is to throw the files directly to Android developers, who will directly call the interface in the files to communicate with the hardware. What is the best way for Android developers to use dll files, wrap them with other layers or rewrite them in another language 需求:我用C#语言写了一个独立模块(单独一个dll文件),主要是通过COM口实时监控一个硬件,基于Win7系统写的。原来是给WPF程序调用的,现在是安卓系统上app也要调用这个dll文件。应用场景是一个硬件设备上连着一个安卓平板,平板上有一个app要调用我的库文件监控硬件,没有网络,计划是将文件直接丢给安卓开发人员,安卓开发人员直接调用文件里的接口与硬件通讯。哪种方式能更好的使安卓开发人员使用dll文件,外面用其他需要封装一层还是用其他语言重新写11KViews0likes7CommentsMultiple tables in MVC application
Hello all, I am new to the ASP.NET Core and MVC development. My goal is to create a simple Movie Management Web Application, just like the one in this tutorial: https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/start-mvc?view=aspnetcore-6.0&tabs=visual-studio I already followed this tutorial 2 times, to learn the concept. But there is something missing. I want to separate the Genre from Movie in my database. I must have two tables: Movie and Genre. They must be linked by the Foreign Key GenreID in the Movie table. As the above tutorial doesn't show me how to do it. I would like to get your help here. How do I generate the database properly from my models? PS: I already created two Models classes: Movie and Genre. After scaffolding, only one table was generated in the database: Movie. The Genre table was completely ignored. Thank you2.1KViews0likes7CommentsWhat platform/technology/framework to use. I am lost. :-(
Hi everyone, I want to develop a new application that will run on Windows (desktop app) and android. I have about 30y of experience in development and the last 15 in C#/VS/.NET. At work we work with Winforms/WPF and .NET 4.8. For my personal new product I would like to start with all the latest and greatest but it's hard to find what to use. First of all I upgraded to VS 2022. I've been reading about .NET5/6, Xamarin, Xamarin Forms, .NET MAUI, Win UI, Winforms, WPF, UWP, Blazor, .NET Core, .NET Standard,.... but it's a mess to get an overview of what would fit best. The project would have 1 or 2 core assembly's with the logic and then a UI for Windows and one for Android. So before I start I would like to get an idea of what you would use. Thanks!Solved11KViews1like7Comments- 82KViews1like7Comments
.NET 8.0.2 Update Causes ASP.NET Core MVC 'Index View Not Found' Error
Hello everyone, I recently updated to .NET 8.0.2 and encountered an issue with my ASP.NET Core MVC application. After the update, the application began throwing an error related to the 'Index' view not being found. This issue was not present prior to the update. An unhandled exception has occurred while executing the request. System.InvalidOperationException: The view 'Index' was not found. The following locations were searched: /Views/Home/Index.cshtml /Views/Shared/Index.cshtml This error is generated by the Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware and specifically indicates that the MVC framework is unable to locate the 'Index.cshtml' file in both the 'Home' and 'Shared' directories, where it traditionally searches for views. I've verified the existence of the 'Index.cshtml' file in the correct location and ensured that the routing configurations are set up correctly. This setup was working seamlessly before the update to .NET 8.0.2. Update: I was able to resolve this issue by uninstalling the .NET 8.0.2 updates. After reverting to the previous version, the application started working as expected without any errors. It appears that the .NET 8.0.2 update may have introduced a change or incompatibility affecting the way ASP.NET Core MVC applications locate views.32KViews2likes6CommentsMVC Controller Method Overloading
Hi Folks, The application is built using .NET Framework 4.5.2 with MVC pattern. The current situation requires validating the input parameter and redirecting to the respective method. public ActionResult GetSomeData() { // Default execution for given route } public ActionResult GetSomeData(int inputValue) { // Route detection with the input parameter and change the functional flow for INT data type } public ActionResult GetSomeData(string inputString) { // Route detection with the input parameter and change the functional flow for STRING data type } Is such redirection possible? Thank you for reading.2.5KViews0likes6CommentsThe SSL connection could not be established
We have developed an application using Microsoft.Net Core. The application has a function that generates tokens and executes an API call. Suddenly the application is throwing an error while generating the token. When we test the application, the same application is working on Windows applications but not on Windows servers. It would be helpful if anyone could guide us on how to resolve this issue Exception from server: System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> System.ComponentModel.Win32Exception (590615): The context has expired and can no longer be used. --- End of inner exception stack trace --- at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm) at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage request) at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellation(CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.HttpMessageHandlerStage.Send(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpMessageHandlerStage.Send(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.SocketsHttpHandler.Send(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpMessageInvoker.Send(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.Send(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken) at System.Net.HttpWebRequest.SendRequest(Boolean async) at System.Net.HttpWebRequest.GetResponse()7.1KViews1like6CommentsASMX web service client .NET 6 (IOS)
Hello, We need to migrate own Xamarin iOS application to .NET 6 iOS. But we can't call ASMX web services (available with Xamarin iOS). Web References is not available with visual studio for .NET 6 projects. We have only Connected Services but it's not supported. Have you an idea for that? Connected services will be supported? You will find more information here: https://docs.microsoft.com/en-us/answers/questions/689592/asmx-web-service-client-net-6-ios.html?childToView=6921193.1KViews0likes6Comments