Closed AlseinX closed 5 years ago
I am also facing this issue with dot
name library application. The wwwroot
assets are not loaded in server-side Blazor application.
The application is working as expected while renaming the library app into RazorLib1
. Could you please provide some quick fix for this issue.?
I am also facing this issue with
dot
name library application. Thewwwroot
assets are not loaded in server-side Blazor application.The application is working as expected while renaming the library app into
RazorLib1
. Could you please provide some quick fix for this issue.?
You can access by replacing the Test.RazorLib1
to testrazorlib1
from the url and it should work on server side hosting, but it stops working on client side hosting. :-<
@AlseinX : Yes, it will work, but we need generic solution for all the hosting models of Blazor.
@karthickthangasamy Me too.
Thanks for contacting us, @AlseinX. @javiercn can you please look into this? Seems like something we'll need to normalize on.
It is expected that blazor client-side will also move to use _content/<
@javiercn
You can access by replacing the Test.RazorLib1 to testrazorlib1
Struggled with this as didn't know I had to replace the dotted project name with lowercase without dot. AFAIK dots are allowed in the path part of a URL. Also case is ignored in URLs
Whats the reason for this
Unlikely but if I had 2 projects of same name but only differing by dot this would break.
Project.Test ProjectTest
@mikes-gh dots are allowed, but normally cause issues, with many proxies and redirection rules, because people write simple rules like . to refer to files and that causes problems.
Urls are case-sensitive. Many static files implementations simply rely on the file system casing, that's why in some cases they can seem case insensitive, and you can choose to interpret them that way, but in HTTP they are case sensitive, if not, try to set a cookie path to /PATH and visit the site at /path and you'll see how the browser doesn't send the cookie.
@javiercn thanks so is the plan to use lowercase no dots for both client and server.
@mikes-gh yes
@javiercn can I ask why the _content
prefix for this feature?
It doesn't seem very intuitive to me..
Maybe the static path prefix could be made configurable in the csproj of the library
Whilst convention is good to keep code down in this case it may be less confusing to state the path particularly because the rule is a bit awkward.
Just my 2c and I am sure you have lots of other priorities :smile:
Another thought I had which may make more sence naming wise is to replace dots with hyphens.
_content/Blazor.Lib.
becomes _content/blazor-lib
seems a bit better to me and looking at conventional js libraries this seems to be a common pattern
@mikes-gh We use _content by default to clearly distinguish what's directly from your app with what comes through static web assets, as a safe way to avoid collisions and keep everything under a common subspace of the url address space.
@javiercn any thoughts on replacing dots with hyphens instead of removing them
e.g.
_content/Blazor.Lib
. becomes _content/blazor-lib
We are planing to go back to _content/$(PackageId)
as the default convention.
@javiercn - I agree with your desision. At the moment the docs say _content/{LIBRARY NAME}/
Does LIBRARY NAME
mean the csproj name?
I think its possible to use a RCL from a project reference that doesn't include a <PackageId>
i.e. an RCL that has never been packed? This might happen when testing.
Forgive me if I'm missing something just coming at this from an end-user perspective.
$(PackageId) is always defined, even if you don't pack your project. It will work whether you pack the project or reference it
Fixed in https://github.com/aspnet/AspNetCore-Tooling/commit/98b168c8947d8c7f7b3f2beb3a0561fb89cadfb5
This will be in preview7
@javiercn
And another problem is, making a blazor component library that supports client-side hosting still needs specifying the wwwroot
folder instead of content
(which is in the dotnet new blazorlib
template) manually while the server-side support takes `wwwroot
as default name convention.
<EmbeddedResource Include="wwwroot\**\*.js" LogicalName="blazor:js:%(RecursiveDir)%(Filename)%(Extension)" />
<EmbeddedResource Include="wwwroot\**\*.css" LogicalName="blazor:css:%(RecursiveDir)%(Filename)%(Extension)" />
<EmbeddedResource Include="wwwroot\**" Exclude="**\*.js;**\*.css" LogicalName="blazor:file:%(RecursiveDir)%(Filename)%(Extension)" />
Is it planned to make client-side and server-side use the same way shipping static assets?
Additionally, the static assets is embedded as resources and also copied to the dist _content/...
folders when publishing a client-side hosted blazor application, does it mean the browser need to download static assets twice, for once directly via the _content/...
path and once within the dll?
dotnet blazorlib is going away in favor of simply using razor class library.
Regarding the embedded files I would have to take a look. It might have been something blazon specific that we didn’t remove.
Closing as we’ve taken action.
@javiercn
I am still confused that the razorclasslib
template creates a library with .cshtml files while blazor uses .razor files. Does cshtml work also with blazor?
And the razorclasslib
targets netcoreapp3.0
while the client-side blazor template targets netstandard2.0
. How could a blazor project reference a razor class library project?
There is a flag for it. We simply default now to support pages and views, but the default will change.
Someone can help me how to make the Blazor SSR website work with a component project. The static files in content folder are not copied to wwwroot.
@minhhieugma : Rename the content
folder with wwwroot
and generate the nuget package using dotnet pack
.
Reference link - https://devblogs.microsoft.com/aspnet/asp-net-core-and-blazor-updates-in-net-core-3-0-preview-6/
nerate the nuget package using
dotnet pack
. @karthickthangasamy Thank guy, it works. Can you tell me how to include script/link automatically as blazor client side rendering can do? I would not like to manual add it!
@minhhieugma : I hope, for SSR we have to refer it manually like the below. Let's wait for others thoughts about including the assets automatically as like client-side application.
<script src="_content/LIBRARY_NAME/example.js
Describe the bug
In preview 6 when there is a wwwroot folder in a blazor library project, the request path of server side and client side are different.
To Reproduce
Steps to reproduce the behavior:
dotnet new
a blazor library project with a name that contains.
.content
folder towwwroot
to make use of the new static assets feature add in preview6.wwwroot
instead ofcontent
(There would even not be any proper url path to the assets with client side hosting if this step is skipped. Question: Why doesn't blazor client side use the new wwwroot support? )dotnet new
a blazor client side and a blazor server side project that reference the library project.Expected behavior
Static assets in both project can be accessed with the same url path.
Actual behavior
The file "background.png" is accessed with different url path: Client side hosting:
https://<hostname>/_content/<TheOriginal.LibraryName>/background.png
Server side hosting:https://<hostname>/_content/<lowercaselibrarynamewithoutdots>/background.png
Consequence
A blazor library with static assets cannot have a name with
.
, otherwise it would have different behavior when referenced by client side and server side hostings.Is there any plan to fix this fault in the futural preview, or some quick fix for the current version?