How to create and access a folder structure in .Net core web API after hosting it on Docker - api

Currently I am using
1. Windows 7
2. Docker Toolbox
3. Visual studio 2017
4. Asp.net core 2.0 Web API
Problem:- First I have created an asp.net core 2.0 web API, which uses a physical path for reading files. It was running perfectly before hosting it to docker.
Then I have enabled support for Docker, build and run the image.
When i try to hit the URL it is giving me exception that "could not find the part of path"
You can see How I declared a path here. Is that right way to do this? Or do I need to make some changes to dockerfile?

Docker toolbox runs on virtual machine but the path I was given is of my windows machine. As I am creating the image on Linux container I also need to map location from where it can get the data file.
It solves the problem when I mapped the app folder while running the container.

Related

How to host a Blazor ServerSide app on a VPS

I'm experimenting with the Blazor Server App and want to host it on my own VPS. I followed about every official documentation there is, but I can't get it to work.
VPS info:
Runs on Hostinger -> Ubuntu 18.04 64bit with Webmin
Installed all required dotnet versions on VPS:
When creating a test index.html and place it inside var\www\html\ it can be accessed through a browser and the content is shown
Blazor Server App info:
Start a new project > Blazor Server App > Publish > Local folder
Copy files from bin\release\netcoreapp3.1\publish* into VPS\var\www\html\
The files can be seen when browsing, but nothing executes
What am I missing here? How can what I want to do be done?
I was expecting the application to run, just like it did when executing it in Visual Studio.
I followed this tutorial based on a similar question
https://www.jeremymorgan.com/blog/linux/blazor-in-linux/, but I'm not using CentOS so it did not help much.

How is it possible to overwrite a dll file in web root folder while IIS is running the app?

I want to overwrite a file in the web root directory of an ASP.NET Core application running on IIS. I copy the file remotely but it say that the file is under the use and cannot overwrite. How can I copy dll files remotely while ISS is running?
If the App within IIS can be set offline briefly, you can use app_offline.htm
The App Offline file (app_offline.htm) is used by the ASP.NET Core Module to shut down an app.
If a file with the name app_offline.htm is detected in the root directory of an app, the ASP.NET Core Module attempts to gracefully shut down the app and stop processing incoming requests. If the app is still running after the number of seconds defined in shutdownTimeLimit, the ASP.NET Core Module stops the running process.
Source: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/app-offline?view=aspnetcore-6.0
If the app needs to keep running the solution with Shadow Copies mentioned by Lex Li in the comments might be helpful.
Note: Shadow Copys are still experimental in .net 6. At the moment this feature still is experimental as far as I know. this discussion might be helpful:
https://github.com/dotnet/AspNetCore.Docs/issues/23733

Kestrel / IIS Express requires restart before edited .cshtml view changes are shown in browser

I'm in the process of setting up my first ASP.NET vNext web application project.
I've got as far as getting the default project to build and run fine in both Windows and OSX. I've tested with kestrel on the mac, and in Windows IIS Express along with kestrel.
The problem I have encountered is that in Windows, editing a cshtml View file while the web server is running isn't reflected when I next refresh the browser.
In OSX, I can run 'dnx web' and navigate to localhost:5000 and browse the site. I can then edit the .cshtml View files, switch back to the browser, hit refresh, and I can see all the changes. This is what I expect to happen and happened in previous versions.*
In Windows, I can either run dnx web or IIS Express on the same site as I was using on OSX, navigate to localhost:5000 (or for IIS Express its own port number) and browse the site. I then switch to edit the cshtml View files, but when I switch back to the browser to reset, the changes aren't shown. It's not until I restart kestrel or IIS express that the changes are shown.
Curiously, however, I can edit a .cs Controller file and the site then recompiles by itself and I don't need to re-start it - in Windows at least. (In OSX, editing a controller file doesn't cause an auto-recompile, but that's an aside, I believe dnx-watch will fix that).
Is there something that I've missed in the project.json, or another setup file, which is causing the issue in Windows?
I have tried:
creating a second completely clean web application project
reinstalling ASP.NET
desperately, lastly, creating a clean install of Windows 10 with Visual Studio 2015 Community Edition, to no avail
What's the way to get Kestrel or IIS Express in Windows to serve the updated cshtml View file after it's been edited, without restarting the server?
*side note, ASP.NET MVC in OSX is awesome!
Following on from #SRQ Coder's response, in particular the reassurance that it's supposed to work as I hoped, I found the reason but as yet no decent solution.
My project directory is located on a network share and I load the projects directly from there (I run Parallels Desktop on a mac). This works great with ASP.NET 4.x / MVC 5 (and earlier). However it looks like ASP.NET 5 doesn't support this setup.
The moment I copied the project folder to the local C: drive it all worked fine
When opening the project from a \\network-share, the project loads and I can run/debug the website, but CSHTML edits aren't shown in browser until IIS Express/Kestrel is restarted
Opening the project from a X:\ mapped network drive doesn't make any difference
I'm not able to recreate your problem on my machine: VS2015; Win10 etc. in either the IIS mode or Web: localhost/5000 mode and on multiple browsers.
I can edit both 'shared' cshtml files like '_Layout' and also the default 'home/index cshtml file with no problem.
Since you've re-installed so much of your system, I'm wondering if you have not re-installed web-essentials and enabled 'browser link'.
I feel your pain...

Deploy MVC 6 app in IIS

I'm using Visual Studio Express 2015RC and I created a simple MVC 6 application, but when I try to publish it I don't see the option to deploy it to IIS, I see the options Microsoft Azure Web App, Import and File System, I tried the File System but It looks like it is more for creating stand alone applications to be launched from a console, now, when debugging I can select IIS Express or the web command, there is no IIS option, so the question is, how can I deploy the MVC6 web application I created to IIS?
File System publish is actually exactly what you want; All DNX applications are stand-alone, whether for ASP.NET 5 or a console app.
When you publish to the File System, you get a few folders; the wwwroot (assuming you kept the default in your project.json) folder is where IIS should point. The web.config in that folder is generated for you automatically assuming you keep everything else where it is.
For what it's worth, the official documentation will probably be here, once it's written. Also, on Stack Overflow, ASP.NET 5 project hosting on IIS probably has some useful information, though it looks like it's a bit out of date at the moment.

How to deploy a web site on IIS by using .dll file

I want to deploy on IIS my web site but I do not want to take whole project. I just need to take .dll file. Is their any way to do so.
I do not want to use visual studio only .dll file from the project to deploy.
The basic steps for deploying to IIS on windows server are as follows:
log onto the machine that is or will be hosting your application.
Use IIS Manager to create a new website for your application.
Create a new application in that site. I believe this also will automatically create an application pool with the same name for you and use it by default.
Specify the virtual directory for your application. This is going to tell IIS where to look for your mvc application. For this case lets assume it is C:\myApp
On your own machine Build the application however you build it with the correct solution configuration (i.e. Release mode). Let say the result of your build is located at C:\MyProject\bin
Copy C:\MyProject\bin from your machine onto your hosting machine at C:\myApp
You should be able to search these steps and find a step by step guide of how to accomplish them. Here is a link to some info on what sites, applications and app pools are to help you better understand.
http://www.iis.net/learn/get-started/planning-your-iis-architecture/understanding-sites-applications-and-virtual-directories-on-iis
Based on your sites requirements there will be some additional steps to set up security and alter bindings if you need to change them.
You don't need to deploy your entire website if you only make a change in a single assembly. You could copy the .DLL assembly directly to the bin folder of your website. This will trigger the Application Pool to be recycled in IIS and the changes will be taken into effect on the next request.