Where point razor folders "_framework" and "_content"?
_host.cshtml
<script src="_framework/blazor.server.js"></script>
<script src="_content/BlazorInputFile/inputfile.js"></script>
there is no inputfile.js nor a BlazorInputFile folder
simple answer for _content: to wwwroot of those library.
what about _framework? Root directory of library?
Related
I am using the C# WebBrowser control. My HTML renders fine. However, I need to keep external files on the local computer. References to the local copy of files do not work.
How do I write the HTML to load locally stored files?
This works:
<script type='text/javascript' src='https://code.jquery.com/jquery-latest.min.js'></script>
This works when loading a file directly in to a browser, but not through the C# WebBrowser control:
<script type='text/javascript' src='./jquery-latest.min.js'></script>
Adding the full path gets rid of error messages, but still does not work.
<script type='text/javascript' src='file:///C:/<full path>/jquery-latest.min.js'></script>
I have tried adding this to the first line of the html file which does not solve the problem.
<!-- saved from url=(0014)about:internet -->
Just put your local js file in the same directory with your html file. Then use this will do
<script type='text/javascript' src='./jquery-latest.min.js'></script>
I'm building the ASP.Net Core Web Application
I installed bootstrap using Quick Install Package. So now I have it in my dependencies:
Also, there's a folder "node_modules" with bootstrap and everything is fine there, all classes are where they're supposed to be:
Then I created a view and in html wrote the following:
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.css" />
When I hover the mouse over the href, I see a warning:
Path C:\Users\Shep\SportsStore\SportsStore\wwwroot\~node_modules not found
Well, it's true, because there's no such folder, but how to keep it from looking in wwwroot and use the specified folder? My wwwroot is empty, I guess it's because I didn't use bower
If I use the full path (href="C:/Users/Shep/SportsStore/SportsStore/node_modules/bootstrap/dist/css/bootstrap.css"), it seems right, but I bootstrap classes are unavailable:
<body>
<div class="panel-info">
</div>
</body>
and if I hover the mouse over, I see "Unknown CSS class 'panel-info'" even though there's this class in bootstrap.css
.panel-info {
border-color: #bce8f1;
}
I'm not using Angular and haven't created any js files of my own yet.
I have seen lots of similar issues and haven't found suitable solution, sorry if it's a duplicate
In ASP.NET Core, the runtime supports a piece of middleware called StaticFiles that allows anything in the /wwwroot folder to be accessible from the browser. But since the node_modules directory is outside of /wwwroot ,that problem occurs .
You can use Library Manager/Bundler and Minifier to copy the files into wwwroot . There are a lot of solutions you could find from here .
I have a .NET Core project in which the master page _Layout.cshtml page references site wide style and js files:
<link rel="stylesheet" href="~/css/site.css" />
<script src="~/js/site.js" asp-append-version="true"></script>
The Index.cshtml page, which utilizes the above master page, references page specific style and js files:
<link type="text/css" rel="stylesheet" href="~/css/landing.css">
<script src="~/js/landing.js" asp-append-version="true"></script>
And then Contact.cshtml and About.cshtml also have page specific css and js files.
What is the correct method to bundle the site wide files with page specific files?
Should I avoid referencing anything the in the master page and simply reference the bundled file in each page's .cshtml?
You reference in your Master Page all scripts and Style Sheets you share across pages. For instance, you could reference only jquery.
You reference in your pages scripts and styles that are used specific on that pages.
It sounds simple like that.
I'm trying to apply localization on _Layout.cshtml
_Layout.cshtml
#using Microsoft.AspNetCore.Http.Extensions
#using Microsoft.AspNetCore.Localization
#using Microsoft.AspNetCore.Mvc.Localization
#inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet
#inject IViewLocalizer LayoutLocalizer
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div style="margin:38px;margin-top:56px;" class="hidden-sm-down">
<h2>#LayoutLocalizer["WelcomeHeader"] <b class="text_border_darkblue">MyTitle</b></h2>
<div style="text-align:center;margin-top:42px;">
#LayoutLocalizer["WelcomeSub"]
</div>
</div>
</body>
</html>
The resource files are named named: Views.Shared._Layout.no.resx (I've tried renaming to views.shared.Layout.no.resx without any luck)
You must create a _Layout.no.resx file within the same path of the views but as a root the "Resources" folder. See sample image:
There is a video clarifying the use of Location see here
Solution
Implement SharedResources with resource files and use Localization on
the SharedResources object in shared Views
You can combine IViewLocalizer and IHtmlLocalizer for _Layout.cshtml. If you define a resource folder inside your Visual Studio solution you can put the resource files there.
If you are using razor pages instead of MVC views inside your ASP.net core application you create a subfolder Pages instead of Views inside the folder Resources. Put the _Layout.no.resx file in there. e.g. Resources\Pages\_Layout.no.resx.
I have 2 projects ABC and XYZ created as 2 separate Virtual Directories in IIS (7). Now my problem is I have many .JS (script) files in project XYZ that need to be bundled and minfied and rendered in an aspx page (containing HTML code) that is available in project ABC. Is this possible ?
Note: Using Microsoft ASP.NET Web Optimization Framework 1.1.1
[http://www.nuget.org/packages/microsoft.aspnet.web.optimization/]
Yes, just use the correct link to the bundle in your other project.
If you bundle is for example defines as
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
which can get accessed via
#Scripts.Render("~/bundles/jquery")
you can use
<script src='http://<host>/<site>/bundles/jquery' type='text/javascript' language='javascript' />
Just as simple as that.
If you have both applications installed on the same website (same root), you can also use relative URLs, e.g.
<script src='/XYZ/bundles/jquery' type='text/javascript' language='javascript' />