0

I have two projects, one is for a website and the other is only for store resources(for example image and video). All of them running on IIS. The images and videos of the website all references from the resources site.

All of them are running with CDN. When I develop my website, open the browser to debug it, it will also get the image or video from the remote CDN. However, I am afraid the price of CDN in my country is so high. I have to waste unnecessary money on this.

I have an idea that when in development, the website references local images and videos only. So I want to specify the port of the resources site only in development.

I found this tutorial: How to specify the port an ASP.NET Core application is hosted on? . However, I don't know how can I make it only work in development. Would you please help me?

Vy Do
  • 46,709
  • 59
  • 215
  • 313
Melon NG
  • 2,568
  • 6
  • 27
  • 52

1 Answers1

1

Use

{
  "profiles": {
    "MyApp1-Dev": {
        "commandName": "Project",
        "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
        },
        "applicationUrl": "http://localhost:5001/"
    }
  }
}

Development will work with your development environment. You can change 5001` to other port number what you want.

Tip: You can use https://github.com/madskristensen/WebEssentials.AspNetCore.CdnTagHelpers

Vy Do
  • 46,709
  • 59
  • 215
  • 313
  • It works! The CdnTagHelpers is an amazing project while it seems does not support port to a local site while in development only. Currently, I am using a Singleton with WebHostEnvironment.IsDevelopment() to achieve it. – Melon NG Jul 10 '21 at 00:05