Blazor project publish doesn't create DLL files - asp.net-core

I have two separate .NET6.0 projects for back-end and front-end. Backend with C# can be published just fine. Front-end is written with Blazor. When I choose publish, it goes through the process without errors or exceptions. It also builds files in the bin>Release>net6.0 directory just fine but doesn't create any of the DLL files in my chosen directory for publish. In that directory, it just creates wwwroot, libman.json and web.config as you can see in the image.
Where can be the cause of the problem?

blazor web assembly app is a static app so it will have much static files, the logic codes you wrote in .razor will be packaged into your_project_name.dll in wwwroot\_framework.
Then when we need to host the app, we need to find a static file server to serve the app. For example, IIS. When publish the static app, we need to create a website and set the website point to the publish folder which containing wwwroot folder and web.config file. Then make sure the IIS had installed url rewrite module since it's a static website. After installing the module, we will see the default rewrite rule like this:

Related

asp.net core share remote or use common wwwroot among apps running behind the load balancer

I have a scenario where I'm using 2 IIS servers running on asp.net core (nopcommerce 4.10) behind the load balancer F5 with sticky session.
Since the nopcommerce doesn't support web farm at the moment, I'm looking for a work around to share the wwwroot folder between these two servers for the images/file and pondering if it's possible to create wwwroot folder somewhere else than app root path so that these 2 app can use it (which is possible if somehow I configure dotnet core app in startup.cs to use wwwroot folder from different path).
Or alternatively share the wwwroot folder for both from one of these.
My current solution is to copy the file on another server when anything uploaded from admin side but this won't work with bundling.
I don't know nopcommerce, but one way could be to setup a network share and map it in to the wwwroot folder and give write permission on it to the application pools. The write permission is just because you wrote that you are uploading files from Admin. I guess you also have things part of the bundling that you want to include in the wwwroot folder?
Like wwwroot/my_upload_folder_share
The comment and answer from Robban1980 helped and I really appreciate it. Although I'm posting my final solution hoping, it will help someone, specifically for nopcommerce developer.
I have override the method for the in FileProvider (nopcommerce uses it for accessing file resources) to take files from my folder instead of taking it from wwwroot.
public override string GetAbsolutePath(params string[] paths)
{
var allPaths = paths.ToList();
allPaths.Insert(0, "my-folder");
return Path.Combine(allPaths.ToArray());
}
Also, I had to set read/write file permission to the folder to make it accessible via a network

Static files in ASP.NET Core works locally but not once published to Azure

I'm building an ASP.NET Core application and need to serve up a few small static files (eventually they'll probably move to a CDN but that's later). All the docs tell you to put static files in the public folder which is what I did:
Locally, when I run the server, it works:
However, when I publish the site to Azure, the page isn't found (it appears to use the React routing or something):
I can confirm the file actually gets published and exists on Azure at /wwwroot/ClientApp/build/Specs/api.yaml so it's not any sort of publishing issue:
I haven't touched the Startup.cs file or web.config, everything should be default. I've also tried other static files, like .htm and .txt to make sure it's nothing to do with the file extension, but same issue. Any ideas?

why bin folder not exists inside wwwroot in my project?

I created empty project asp.net 5 in Visual Studio 2015.
Here how it looks:
As I understand from some tutorials the bin folder have to be inside wwwroot.
But there is no bin inside wwwroot and also bin folder not exists anywhere in Sensor Observation project.
Any idea why bin folder not exists inside wwwroot in my project?
The wwwroot folder is from where you serve static files (e.g. css, images, JavaScript, etc.). Files in the bin folder should never be served to the client (e.g. browser) so it should not go in the wwwroot folder.
Here is some more information on what the wwwroot should contain. Essentially:
"Enter the wwwroot folder in ASP.NET 5. The wwwroot folder represents
the actual root of the web app when running on a web server. Static
files, like appsettings.json, which are not located in wwwroot will
never be accessible, and there is no need to create special rules to
block access to sensitive files. Instead of blacklisting access to
sensitive files, a more secure whitelist approach is taken whereby
only those files in the wwwroot folder are accessible via web
requests."
The wwwroot/bin folder only used to contain one single file AspNet.Loader.dll. The AspNet.Loader.dll was/is used by IIS to load the application (which resides outside of the wwwroot folder).
The reason for this is an increase of security. With ASP.NET Core 1.0 you don't point the application entry to the folder (that contained all the *.cs files in ASP.NET 4.5), but you point it to the wwwroot folder of your application.
Now IIS don't has access to the actual application files (and allow by accidental access to maybe sensitive files). So the AspNet.Loader.dll is required to execute your application.
Other than that, there are no other binary files in wwwroot/bin nor should there be any other.
Update:
This used to be required for Helios to be run/hosted within IIS. Helios has been deprecated with beta8, because it made no sense to develop two different servers. So wwwroot/bin will always be empty for newer versions of ASP.NET Core. If you found posts or references, they most likely reference to an old beta.
Now Kestrel, IIS via HttpPlatformhandler (up to rc1-final version and ASP.NET Core Module with rc2 and newer) and self-hosting via HttpListener are the supported run modes. Though one can also use Kestrel behind an IIS.

Default route in MVC working from VS, but not on test server

I have a very simple ASP.NET MVC 4.0 website. It's got a single controller ("HomeController") with a single action ("Index") which receives a single parameter ("string id"). I have not modified the global.asax file since this kind of route is handled by default. I have not created a view for this action since the action will simply be "sending" the user a file (a PDF). If I run the site from within Visual Studio (using a default page of "home/index/3" in project properties), the page runs fine. If, however, I publish the site to our test server (https://ourserver.com/mysite/home/index/3), I get a 404--File or Directory not found.
NOTE: We're running IIS7.5 on this server.
UPDATE: The bin dir (and the appropriate DLL, i.e., one named after the project) and the web.config file are there.
So, why is this not working?
If you're using an older version of IIS and haven't installed the MVC server extensions which give you routing, you can do a BIN deployment of the necessary infrastructure files.
Edit: If you're running IIS 7.5 you should have everything you need. You mention you don't see a web.config file or any dlls - how did you publish? You should absolutely have a web.config at the root of the publish directory and a bin folder with your dll(s).
If you right-click on your web project and do Publish, you can publish to a local directory. It'll be exactly what you should see when deployed.
Edit 2: Did you check that it's configured in IIS as a web application and not just a site?

deploying wcf service application as a precompiled app

I have a wcf service application that has some application startup code in the app_code folder of the project. When i publish this project to my website, it deploys it with source code and app_code folder.
Is there a way to precompile the wcf app ( like an asp.net app), that includes all the dependencies and compiled code ?
i checked the web deployment package files, and even that has the source code of app_code folder.
problem here really is that since the template for wcf does not expect app_code folder and .cs files in it, they get added as content, changing them to compile would include them in the web dll
Your best bet would be to:
put all your WCF service-related code into a separate class library assembly
deploy that assembly to the .\bin directory
only put your MyService.svc file (without any code-behind) to your virtual directory
With this setup, the WCF service is still being hosted by IIS, but you don't need to do any special tricks and hacks to get it to work properly.