Running multiple projects on an IIS Express server in JetBrains Rider - asp.net

I want to run two projects on an IIS Express server using JetBrains Rider.
I've tried using a compound configuration, but I can't find a way to run two projects on the same server? Is that even possible in Rider? In Visual Studio it works, how does Visual studio do this?
Is there any changes I can make to my local .idea applicationhost.config to fix it?
Thanks!

It definitely is possible to run multiple ASP.NET Core IIS Express projects in JetBrains Rider simultaneously. There's a known issue that it requires some additional/manual settings: RIDER-32933. There's a workaround explained in the comments which I'll briefly duplicate here.
IIS Express natively supports running multiple sites using the same configuration file, and Rider uses this ability to some extent. The only issue is that it overwrites IIS config on starting each application, which leads IIS Express to kill any previously started application instance.
From your question, I conclude that you've already created the appropriate run configurations for your apps, so I won't explain it here (but here's a link to the corresponding documentation if you need help).
So, first, you'll need to make Rider to create a proper applicationhost.config for you. To do that, run every configuration you want to run simultaneously at least once. E.g. if you have two apps, "WebApplication1: IIS Express" and "WebApplication13: IIS Express", you'll need to start each of them once.
After you've done that, Rider will generate an appropriate configuration file in .idea/config/applicationhost.config in your solution folder. Important section is:
<sites>
[…]
<site name="WebApplication" id="1">
[…]
<bindings>
<binding protocol="http" bindingInformation="*:49901:localhost" />
<binding protocol="https" bindingInformation="*:44375:localhost" />
</bindings>
</site>
<site name="WebApplication13" id="2">
[…]
<bindings>
<binding protocol="http" bindingInformation="*:26835:localhost" />
<binding protocol="https" bindingInformation="*:44339:localhost" />
</bindings>
</site>
</sites>
So, after you have both of your sites in this config, you'll need to disallow Rider to touch the config. Do that by opening the run configuration settings for both of your configurations and unticking of the Generate applicationhost.config checkbox:
After that, you may either start both of your configurations manually (by selecting each one and pressing the Run button), or using a compound configuration. Debug will work, too.

Related

Failed to find a valid digest in the 'integrity' attribute for resource in Blazor app

I have a Blazor client/server app that I have been working on for a period and it has been working fine up to now. I suddenly started getting this error
Failed to find a valid digest in the 'integrity' attribute for
resource 'https://mydomain.no/_framework/Faso.Blazor.SpinKit.dll'
with computed SHA-256 integrity
'1UEuhA1KzEN0bQcoU0m1eL4WKcCIWHhPgoXydAJnO9w='. The resource has been
blocked.
Failed to find a valid digest in the 'integrity' attribute for resource
I have tried to clean and rebuild. I have tried to add Cors, set folder permission, and many other suggested solutions, but to no avail. I am using web deploy in VS 2022 and Win Server 2016, .net core 5.0.
Any suggestions would be appreciated.
This is an annoying issue indeed and I'm getting that error every now and then. It seems to happen after updating some packages, and the build processes fails to pick up the new SHA for the package.
You can verify that this is the issue by finding the file containing the SHAs and compare the SHA for the dll in question with the SHA from the error message.
This file is called blazor.boot.json and is generated deep inside the obj-folder of your project folder.
(mine was here: obj\Release\net6.0\win-x86\PubTmp\Out\wwwroot\_framework)
If was the issue, please try this:
Close VS.
Delete the obj and bin folders from all your projects. (the web project might be enough, but hey - can't hurt)
Start VS
Rebuild solution.
Try Publish again.
All answers here are great.
The only caveat to my solution was that I was using a hosted Blazor WASM model. Since we publish our Server application, it takes the liberty to build the Client for us. After seeing every single solution say to delete your bin and obj folder and then banging my head on every wall in our office it finally dawned on me that I don't need to be deleting the bin and obj from my "Server" project and that I might need to go to the Client project and do that.
It might sound simple enough in hindsight, but coffee failed me this morning. At the expense of my pride.. hopefully this can be someone's light bulb answer. Sometimes YOU are the little things. :D
I finally solved it for my own issue! This issue has been plaguing me for weeks.
I had tried all of the things mentioned here and elsewhere, and none of it worked. What did work was using my ftp client (filezilla) and changing the transfer type from "auto" to "binary" (Transfer > Transfer Type > Binary). I don't see an option for doing this in VS2022, so I guess I'll use my manual ftp client solution for now.
Aaaahhhhh.
Check this note from: https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-6.0
Resolve integrity check failures:
When Blazor WebAssembly downloads an app's startup files, it instructs the browser to perform integrity checks on the responses. Blazor sends SHA-256 hash values for DLL (.dll), WebAssembly (.wasm), and other files in the blazor.boot.json file, which isn't cached on clients. The file hashes of cached files are compared to the hashes in the blazor.boot.json file. For cached files with a matching hash, Blazor uses the cached files. Otherwise, files are requested from the server. After a file is downloaded, its hash is checked again for integrity validation. An error is generated by the browser if any downloaded file's integrity check fails.
If after deleted obj and bin folders the error continues, be sure that you are deleting the cache on your client browser of the site (Ctrl + F5)
My solution is also so interesting. I put my web api service and Blazor Wasm projects into same server with different subdomains. Both of them are using .Net 6.
Although Web Api works well, Blazor gave that error. I tried everything on the StackOverflow, none of them worked. Then I tried to move Blazor project to another server that another Blazor Wasm is already working and Bingo!
While it gave problem in Windows Server 2022 with IIS 10.0.20348.1 and .Net Core Hosting Bundle 6.0.7; it worked in first try with the same files in Windows Server 2019 with IIS 10.0.17763.1 and .Net Core Hosting Bundle 6.0.6
I am really so surprised that why it gave error in new server and I couldn't understand where is the problem exactly (Server edition, IIS or .Net minor version differences)
I hope it helps to someone that couldn't solve problem yet.
For me (I've updated the SDK from .NET 6 to 7), the solution was the following order of action:
Clear all bin and obj folders
Clear all nuget cache instruction
Run the app and clear the browser cache (Ctrl+F5)
For me it was wrong MIME Types.
There was a web.config with changes to Mime types, but I needed to mannually change it for my Blazor Page in IIS.
After this it worked
Web.config in Publish folder contained a section like this:
<remove fileExtension=".blat" />
<remove fileExtension=".dat" />
<remove fileExtension=".dll" />
<remove fileExtension=".json" />
<remove fileExtension=".wasm" />
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".blat" mimeType="application/octet-stream" />
<mimeMap fileExtension=".dll" mimeType="application/octet-stream" />
<mimeMap fileExtension=".dat" mimeType="application/octet-stream" />
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension=".wasm" mimeType="application/wasm" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff" />
This conflicted with the Mime Settings in IIS
After I changed the Mime Settings in IIS to the values from the web.config, it worked.
For me, it happens if I run the same blazor app in the same browser user but with different domains. ex:
'mywebsite.z13.web.core.windows.net' and 'mywebsite.com'
Delete the cache, and run only 1 domain per browser user.

Visual Studio Solution with API and SPA - how to run at the same time

I have a visual studio solution with two projects. Both projects are using .net framework 4.7.2. One project is the SPA (single page app) and the other one is an API web project. In VS, when I start an instance of either project, I am able to use IISExpress through Visual Studio in order to navigate to the local host. However I cannot run both at the same time in order to access the API through the SPA. I have done multiple things using IIS Express command line in order to try to get this to work, but to no avail. Could someone please point me in the right direction?
Thank you
By default, a single project selection is configured as a startup project but you can set multiple projects as well.To start multiple projects at a time in Visual Studio you could follow the below steps:
1)open visual studio and go to Solution Explorer.
2)Click on properties
3)By default, a single project is set as the startup project.
4)Select multiple project options and change project status to start which needs to be started.
5)Run the application, you will see two projects loading in the browser.
This can be done using “Multiple Startup Projects” property of the solution.
Visit the following documentation for step by step instructions
https://learn.microsoft.com/en-us/visualstudio/ide/how-to-set-multiple-startup-projects?view=vs-2019
here is some step to follow:
1. right-click on the solution name.
2. Click on properties.
3. Select 'startup project' under Common properties.
4. Select on multiple startup project.
5. change the action of the two projects from none to 'start' then click apply and ok.
6. After that you can normally run your project by clicking the start icon.
link for referenece.
In the end I was able to figure out how to use IIS Express to run both at the same time. I edited the application applicationhost.txt in C:\Users\XXX\Documents\IISExpress\config
(redacted personal data with Capital Letters)
<sites>
<site name="API" id="999">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\XXX\source\repos\YYY\YYYZ" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:1132:localhost" />
</bindings>
</site>
<site name="FrontEnd" id="989">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\XXX\source\repos\XXX\XXXZ" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:8080:localhost" />
</bindings>
</site>
</sites>

Access IIS Express from Web API from

First let me say this used to work in Visual Studio 2015 but I am having the a darn hard time getting it to work in Visual Studio 2017.
I have a WebAPI project running in Visual Studio 2017. I have edited the applicationhost.config file in the …\ProjectName.vs\config file so it has the following entries for my project.
<bindings>
<binding protocol="http" bindingInformation="*:56952:localhost" />
<binding protocol="http" bindingInformation="*:56952:192.168.1.155" />
</bindings>
My firewall is completely disabled. When I try to run my Xamarin forms project on a Win10 Mobile V10.0.15254.0 emulator my app does not connect to the WebAPI. (I get the standard "The text associated with this error code could not be found. A connection with the server could not be established."
If I launch Edge on the emulator and try to access any of my local servers on the network using IP address, that works. Can someone enlighten me with regard to what has changed and how I can now make this work?
So the issue was the IP address I was using. Here are the steps I used to resolved this:
I launched my Windows 10 mobile emulator.
Click on the >> (Tools) icon in the tool bar of the emulator.
Click on the Network tab of the Additional Tools window.
I looked in the list for the network adaptor labeled Desktop Adaptor #1 and copied the IP address.
Edit the Applicationhost.config file in the folder of the WebAPI project.
Find the entry in the file for site name="XXXXX" where XXXXX is the name of the Visual Studio project you are hosting your WebAPIs in.
Within the <bindings> section of the entry for your WebAPI project, add a binding for the IP address you copied from in step 4. It should look something like this:
<binding protocol="http" bindingInformation="*:56952:169.254.69.220" />
Where 56952 is the port my IIS Express is hosting the WebAPIs on and 169.254.69.220 is the IP address I copied from step 4.
After adding this, I was able to connect to locally hosted WebAPIs in IIS Express.
Hope this helps.

Debugging ASP.NET cloud project over LAN

I've been trying to debug this ASP.NET cloud project over LAN, because we need it for testing at work. I have done plenty of research on the subject, but I simply cannot get it to work as expected. I think I have narrowed the problem down to being that, the project is a cloud service project.
If I create a new ASP.NET MVC project, without the cloud service, it works just fine, when editing the projects bindings, plus turning off the firewall of course. If I then do the same procedure, but with a cloud service project, with the asp.net mvc as the web role, I get "connection refused" when trying to access it over LAN.
Does anyone have any idea what's going on and/or how to solve it?
Bindings:
<bindings>
<binding protocol="http" bindingInformation="*:5807:localhost" />
<binding protocol="http" bindingInformation="*:5807:*" />
</bindings>
I spent almost a full day at work with exactly the same issue.
It finally started to work after I reïnstalled IIS express.
Uninstall at Programs and Features
Download the Microsoft Web Platform Installer found at link below:
http://www.microsoft.com/web/downloads/platform.aspx
search for IIS express, and install it.
After that, it worked like a charm for me. I hope it works for you as well, because I wasted way too much time on this problem...

Deployment of multi-project MVC4 solution to Azure fails

This is my second deployment to Azure.
First was a simple MVC4 Website with a Database, which I deployed via git. Worked like a charm.
Now I've got the following:
A solution containing three projects.
Web -> Which is the MVC4 Frontend
Models -> Contains the Models and the DB Context
Backend -> MVC4 Project for data administration
All projects are MVC4 (didn't know how to manage this better for the Models project).
In my models project I'm running the code-firt migrations.
The backend is running in the virtual directory: localhost:80/Backend
(works perfect on localhost)
Both the Web and Backend project have references to the Models Project.
Folder structure:
Solution folder contains:
Web / Models / Backend / MySolution.sln
The first time I deployed I've created a git repo in the Projects folder (cause it was a single project). Now my repo is in the solution folder.
I'm also uploading files in the Backend and move it to the other project (Web) via the following path:
Directory.GetParent(HttpContext.Current.Server.MapPath("~")).ToString() + DirSeperator + "Web" + DirSeperator + "Store" + DirSeperator;
Is this going to a problem on Azure?
So my loose question is now, how am I deploying this solution?
I've created a Website with Source control in Azure and added a SQL Database to it.
I've managed to push the solution to Azure,
but on Azure there's the messsage
Found solution ... with no deployable projects. Deploying files instead.
now.
Do you have any good tutorials for me on this problem?
Am I doing it completely wrong? (I think so)
I'm relatively new to ASP.NET and Azure, so it's a bit hard for me to understand.
Thanks,
Tobi
Followup Edit: I see now, this has more to do with configuring 2 project deploys. You will need to create deployment scripts
I'm not done doing research, but take a look at these posts:
http://blog.amitapple.com/post/38419111245/azurewebsitecustomdeploymentpart3
http://kellyhpdx.wordpress.com/2012/04/11/deploying-multiple-web-applications-to-a-single-azure-instance-and-applying-web-config-transforms-correctly/
I've managed to solve my problem.
Sorry, that I'm answering my own question - hope this doesn't offend anyone.
What I wanted to achieve is not possible with Azure Web Sites, but with Web Roles.
As seen here on CloudCover and on StructureTooBig.
So I've created a new Azure Cloud Application (provided by the Azure Tools) in Visual Studio, with a default Web Role, which is my Web Frontend project.
I've added a VirtualApplication to the Web Role with the name "backend" and the physicalDirectory set to my Backend Project path.
Then I've added a VirtualDirectory "store", which I could access from both projects for file uploads.
My WebRole looks like this now:
<WebRole name="MvcWebRole1" vmsize="ExtraSmall">
<Sites>
<Site name="Web" physicalDirectory="[projectpath]">
<VirtualApplication name="backend" physicalDirectory="[projectpath]">
</VirtualApplication>
<VirtualDirectory name="store" physicalDirectory="[projectpath]">
</VirtualDirectory>
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
<Imports>
<Import moduleName="Diagnostics" />
<Import moduleName="RemoteAccess" />
<Import moduleName="RemoteForwarder" />
</Imports>
I'm accessing (read+write) the store now via:
HttpContext.Current.Request.MapPath("/Store" + DirSeperator);
instead of
Directory.GetParent(HttpContext.Current.Server.MapPath("~")).ToString() + DirSeperator + "Web" + DirSeperator + "Store" + DirSeperator;
Which works perfectly on both projects.
So, this solution works and I've already deployed it to production!
Emerging problems:
Web Sites work with git integration, but Cloud Services won't (this is very bad for my workflow).
The deployment takes about 30-45 minutes. Holy ...
I've had to publish everything again to activate Remote Access and WebDeploy features. And I hope, WebDeploy is going to save time for deploying updates ... as everytime I'm updating now, the complete solution is replaced on server (within the mentioned time span).
Is there a way to access the data via FTP?
Ciao

Resources