Recent Comments



Aroldo Peixe
Yesterday

re: External Network Access to Kestrel and IIS Express in ASP.NET Core

Great article! How can I do on linux (Ubuntu 16.04)? Thank you.


Christopher Bseirani
Wednesday

re: ASP.NET Core and CORS Gotchas

I was banging my head for two days trying to figure out how to apply CORS to my API...I was following MSDN and it was not working for me - I use your example and it works perfect. THANK YOU!!!


Rick Strahl
Wednesday

re: Updated ASP.NET Database Resource Provider

@Pliskin - Localization resoures are cached by the location framework in ASP.NET - regardless which dev platform (MVC, WebForms) you use. You need to either restart the AppDomain, or if you're using the localiztion provider mentioned here you can force the resource cache to be cleared. But either way these operations have to be explicitly performed - they don't happen automatically.


Rick Strahl
Wednesday

re: Web Browser Control & Specifying the IE Version

@Pablo - 1 - no you can't run the developer tools. They are not part of the control, they are part of the IE Application shell which is not part of the Web Browser control. You can however use FireBug Lite as an addin to at least get proper Console Output.


Pliskin
Wednesday

re: Updated ASP.NET Database Resource Provider

Hello,

This provider id helpful, I have a question; I have two web projects(ASP.NET MVC and Web Form), If I use this provider in MVC project and update resource texts, can I see the new text in web Form project without restarting?

Thank you


Pablo
Wednesday

re: Web Browser Control & Specifying the IE Version

Hi Rick, firstly thank's for your help, this aricle is very helpful and sorry for my english. I have two questions:

1.- Is it possible to run te developer toolbar from webbrowser component with F12 like Internet Explorer?

2.- What is the relation beetwen de and . I don't understand that: "Internet Explorer 11. Webpages are displayed in IE11 Standards mode, regardless of the !DOCTYPE directive."

I hope I have explained it well. Thank you


crokusek
Tuesday

re: Capturing Performance Counter Data for a Process by Process Id

Looks like there is a race condition with the workaround that searches on prefix combined with @Andrei's comment.

  1. The workaround determines the instance name by looping on prefix and matching Pid. Say its "Chrome#9".

  2. Then Chrome#1 happens to exit. @Andrei indicates Chrome#9 becomes Chrome#8.

  3. The program then tries to create new PerformanceCounter on "Chrome#9" however it is no longer the original Pid or it does not exist at all.


Maverick
Tuesday

re: Updating my AlbumViewer Sample to ASP.NET Core 1.1 and Angular 4

If I want to deploy as a single web application, how do I go about it after executing ng build and having all the build files in wwwroot folder of .netcore project? Also, how do I run it in dev environment as a single web application? If you can shade some light on the above questions, it will be very helpful. Thank you.


Maverick
Tuesday

re: Updating my AlbumViewer Sample to ASP.NET Core 1.1 and Angular 4

Thank you for answering my previous question. However, I did not completely understand this part:

"If you don't want to run two separate Web sites/virtuals for your front end and backend code you can still generate all of your output into the server's wwwroot folder easily enough. In fact I set up my angular-cli.json file to point at the wwwroot folder in the server project."

I did see the files getting added after I do ng build, into wwwroot folder of .netcore project. What I dont understand is:

  1. What about the html files in angular project, because the build only contains *.js files?
  2. After the build into wwwroot folder, how do you access the angular files or connect the angular files to existing .netcore cshtml pages?

Thank you for your help in the matter.


Rick Strahl
Monday

re: Updating my AlbumViewer Sample to ASP.NET Core 1.1 and Angular 4

@Maverick - if you have two separate sites altogether you just publish both sites completely separately. Or you can automate with MSDeploy from batch/ps file.


Rick Strahl
Monday

re: Using Let's Encrypt with IIS on Windows

@Niko - I'm not sure exactly when LetsEncrypt starts the renewals, but I believe it's at 60 days. All I know is that my renewals just happen automatically with (AFAIK) no hiccups of downtime due to missed renewals.


Rick Strahl
Monday

re: Updating my AlbumViewer Sample to ASP.NET Core 1.1 and Angular 4

@Steven - the MVC stuff in this project is just to show it as a demonstration, but it isn't used in the Angular piece of the application. I don't use MVC (as in server pages) in the Angular code. The Layout and MVC Controller are for a separate demonstration of generating a separate set of server driven pages for display end edit.

I should probably remove that code since several people have been tripped up by that.


Jose
Monday

re: External Network Access to Kestrel and IIS Express in ASP.NET Core

Excellent work AlbumViewer sample Angular 2.0 application

Its possible add infinite scroll?


Steven
Monday

re: Updating my AlbumViewer Sample to ASP.NET Core 1.1 and Angular 4

Thanks for the post Rick. I just recently started learning Angular and had a quick question about separating the client code from server code. In your server project, the _Layout.cshtml file references "scripts/angular/angular.min.js" (among others). I can see the actual file reference is to the script bundle.js in wwwroot. When I run "ng build" (and set the outDir to MyServerProject/wwwroot), I get bundles for main, polyfills, etc, but nothing for "scripts.bundle.js". What am I missing? Really appreciate your help connecting the dots!


scott moses
Monday

re: Updating my AlbumViewer Sample to ASP.NET Core 1.1 and Angular 4

Great article Rick. This is the workflow I've been using with angular cli in one project and asp.net core api in another, and publish angular cli production code to the wwwroot folder.

  1. how do you change your angular code to call static json or similar in test mode, and the web api in prod?

  2. I'm struggling with the best way to work in identity/auth with this set-up. how do you work this part?


Niko
Monday

re: Using Let's Encrypt with IIS on Windows

My question of 18 April is still unanswered. Somebody should have made experiences because Letsencrypt is not new but for me a relative new theme. Maybe somebody has an answer for me, when the scheduled task job makes the renew earliest? Thanks and regards Niko


Maverick
Monday

re: Updating my AlbumViewer Sample to ASP.NET Core 1.1 and Angular 4

Thank you for a very helpful article. If I am having ASP.NET Core and angular 2 web application as two different applications; how do I publish the angular application to IIS as a separate website?


Sean Fackrell
Sunday

re: Strongly Typed Configuration Settings in ASP.NET Core

In case anyone stumbles on this one. You can't use 'IEnumerable' or 'IList' in your config POCO as you can with normal JSON deserialization. If you do, you'll get an InvalidOperation exception when you resolve IOptions. You have to use List instead or presumably a type that can be constructed. i.e.

// This works
public class AppSettings
{
    public List<ApplicationUser> SeedUsers { get; set; }
}

but

// This doesn't
public class AppSettings
{
    public IEnumerable<ApplicationUser> SeedUsers { get; set; }
}

This was using configuration with dependency injection a la

services.Configure<AppSettings>(Configuration);
services.Configure<AppSettings>(Configuration.GetSection(nameof(AppSettings)));

// and then resolved later by the IoC container
IOptions<AppSettings> _settings

with JSON

{
  "AppSettings": {
    "SeedUsers": [
      {
        "UserName": "user1",
        "Email": "user1@gmail.com"
      },
      {
        "UserName": "user2",
        "Email": "user2@gmail.com"
      }
    ]
  }
  }


Edward
April 21, 2017

re: .NET Standard 2.0 - Making Sense of .NET Again

I think that all of this is an utter mess, and that as a developer I do not feel at all confident I should move any of my development (which thus far has been largely ASP.NET on the full .NET Framework on Windows) across to .NET Core or anything else, until all of this has been brought to some level of stability.

In the last 5-10 years, development on Windows has gone from a relatively simple concept with one .NET Framework to build purely Windows client/server apps to today's bewildering array of APIs and "technologies" introduced with Windows 8.1 and 10 and competing mobile platforms.

But what's the incentive to learn any of it? For client-side windowed apps, I could understand learning UWP on Windows 10, but no-one's buying Windows 10 Phones so why bother? Windows 10 tablets still run the full version of Windows so why bother with the Modern UI? Windows 8 and its related phones weren't a hit. Silverlight is dead, and it's relation WPF wasn't adopted as much as MS hoped. Might as well just stick with WinForms! And, as for ASP.NET apps, Windows servers work pretty well and the full .NET Framework is stable and well documented.

Now they're trying to integrate Xamarin and reflection of foreign iOS and Android APIs into the system and bringing on Linux and Mac.

Visual Studio and its ecosystem is becoming ever more saddled and cluttered with the technological debt and I feel its becoming unmanageable.

I do feel that .NET did need to go cross platform - that I agree with. But couldn't there have been a better way?

I honestly do not feel there's enough time in the day anymore to keep up with it all. I feel so sorry for new developers entering this world.

Over many years I already made the transition from VB.NET to C# and from WebForms to MVC. Now it feels I'm being asked to relearn everything all over again. When is this going to stop?


Johnny K.
April 21, 2017

re: Hosting SignalR under SSL/https

Hi thanks for a great article..
I wonder if anyone has an input on doing this from app.config only. I use "Lets encrypt" certificates (valid 3 month and i autorenew) I dont want to "netsh" with new thumbprint, every 3 month. I want to find the cert in store by name and use it in my windows service.

Any comments?


Jaime Hablutzel
April 20, 2017

re: Using Let's Encrypt with IIS on Windows

Caddy is a web server with native integration with Let's Encrypt, https://caddyserver.com/.


Chris
April 20, 2017

re: Entity Framework and slow bulk INSERTs

This article has been very helpful.

I'm importing some external history every week or two and the process generally takes a few minutes. This has gotten that down to 20-30 seconds. Additionally, this functionality is purely administrative so there isn't a user waiting for a mission critical report or action to occur because of this.

If I was importing hundreds of thousands of records I would have to pursue some other solution, most likely due to memory constraints and/or ridiculous wait times.

These little tweaks help solutions that are only importing a few thousand records in scenarios where the time to process can be a few minutes without any repercussions. Obviously in mission critical systems or customer facing web applications where patience is truly a virtue, speed is extremely important as people will simply go someplace else.


Luke Puplett
April 20, 2017

re: Back to Basics: UTC and TimeZones in .NET Web Apps

Reading these comments again, unless Rick is not explaining clearly enough (it's arduous to explain this stuff) then I think Rick is mistaken and that a system using DTO entirely will work for his needs.

@Rick, the DTO is effectively an ISO1806 structure. The offset it stores is from UTC, not from the local time. I believe you do have all the information needed to convert or display or review in many years time, captured in that single format.

(Local time + difference to UTC at the time)

That's all you'll ever need. Come up with a good scenario where that wouldn't work, I can't.

I think storing as UTC is where everyone gets it wrong, it's destructive, it moves the time observed by the user and then throws away the offset.


dan
April 20, 2017

re: Dealing with Anti-Virus False Positives

So, should we start boycott the antivirus products? Let's vote for the AV with the most false positive (I would go for Avast and Kaspersky) and put a banner (we should all use the same banner) "Don't trust Kaspersky" 😃

If this will affect the reputation of the AV product the other AV companies will start to think twice before randomly showing false positive alarms.


Camilo
April 19, 2017

re: A WebAPI Basic Authentication Authorization Filter

It looks very well, but I don´t understand why do you use a filter in a method that doesn´t appear in the custom filter:

[MarvelPressAuthorizationFilter(false)]

For the class is "[MyBasicAuthenticationFilter]". They should be equals, shouldn´t they?


Vasily
April 19, 2017

re: Publishing and Running ASP.NET Core Applications with IIS

Hello, thanks for the article! So I have been working on a Core website for a while now, but have been informed recently that it should be not a Core standalone application but a .net Framework one. I'll have to go a little backwards and redo the whole thing in non-core code. Is there a lot of huge differences from the IT perspective you think?


Jatin Mahesh Arya
April 19, 2017

re: Publishing and Running ASP.NET Core Applications with IIS

I encountered an error: "Invalid URI: The format of the URI could not be determined" while trying to Publish ASP.NET CORE website and Deploy it via the built in Web Deploy feature of **Visual Studio 2015 Community ** edition on **Windows 10 + IIS Server **; After going through your above described information, i was successfully able to:

  • Publish the website using dotnet publish
  • Deploy the website to IIS Server + Windows 10 (after overcoming few environment specific hurdles)

Note: The Publish and Deploy via Web Deploy option of visual studio still fails with the same error specified above (Given i did not implement AuthType NTLM Fix)BUT i was successfully able to Publish the website content when i changed publish method from Web Deploy to File System

Thanks for sharing this valuable information; Really appreciate it!


Jatin
April 19, 2017

re: Publishing and Running ASP.NET Core Applications with IIS

Thanks a lot sir for sharing this information; I did search a lot to find solution to be able to Publish ASP.NET Core website using the Web Deploy but it kept failing due to error:

Invalid URI: The format of the URI could not be determined (Its still failing as i write this comment);

But the work around you did mention to Publish using dotnet publish did help me Publish the website; Followed by i was also able to deploy the website to IIS Server by following the steps you defined for the same! Thanks Again for your Hard Work that went in to creating this content; Really appreciate it!


Chris Nash
April 19, 2017

re: Updating Assembly Redirects with NuGet

Echoing @bloumoord. Is there a way to do this outside the package manager console? It would fix a lot of issues for us if we could run this as part of our CI (Jenkins pipeline).


Rick Strahl
April 18, 2017

re: ASP.NET Core and CORS Gotchas

Are you guys putting the right domains in your CORS headers you are creating?


Rick Strahl
April 18, 2017

re: Using Let's Encrypt with IIS on Windows

@Ben - You have to ensure that server affinity is guaranteed and that when you set up the request it is guaranteed to go back to that very same machine when Lets Encrypt calls back since that machine will be the only one that has the request info to verify. Most likely you have to take the site off the load balancer or run balancer with a single site enabled to make this work. Otherwise - you need to use a traditional route for getting a certificate which is more complicated but doesn't require live validation of the running site.


Jan D
April 18, 2017

re: Using Let's Encrypt with IIS on Windows

I keep getting this error when refreshing through letsencrypt: The ACME server was probably unable to reach http://www.mydomain.com/.well- known/acme-challenge/

I followed the steps listed, but to no avail. Any other suggestions to look at?


Niko
April 18, 2017

re: Using Let's Encrypt with IIS on Windows

Hi Rick, again a question from me.

All the first time installed certs have a duration of 90 days. How many days before expiration date will the scheduled task renew the certs?

( I also modified the automated installed scheduled task job, that runs every day at 9 o'clock a) run with highest privileges b) run also when user is not logged in (admin password is set), because it should run without a logged in administrator.)

Many thanks and regards

Niko


Darren
April 18, 2017

re: ASP.NET Core and CORS Gotchas

Edgar I am also running into the same issue, works fine locally in visual studio but no'Access-Control-Allow-Origin' header is present on the requested resource -- when on the IIS server


Ben
April 18, 2017

re: Using Let's Encrypt with IIS on Windows

Hi Rick

This is a good write-up, thanks.

I am currently setting up a site with two web servers behind Cloudflare loadbalancing (which is still in preview).

I am attempting to set up SSL for these servers using LetsEncrypt-Simple. However, authorisation is failing for server X, since the load balancer is probably routing the request for the answer file over to server Y, and vice versa.

So, my questions are as follows:

  1. How can I set up SSL for all of my web servers behind the load balancer?
  2. How would we configure the renewal process for this scenario?

Thanks


Aluan
April 17, 2017

re: JavaScript JSON Date Parsing and real Dates

Excellent article. I think this is an elegant solution. I really like the advice to just avoid dates in the first place. In addition to preventing a large class of errors, using server formatted strings also makes client side databinding code simpler and staves off any temptation to write god awful, stateful and logic-ridden models.


Rick Strahl
April 17, 2017

re: .NET 4.5 is an in-place replacement for .NET 4.0

@Bill - if you are proficient in Delphi and have been doing it for years, then that's great. But Delphi/Pascal is pretty much a marginal language/platform at this point and while it was always super powerful it also wasn't the most straight forward language to work in. And like many other platforms that have faded from public view, while technical capable finding answers to problems and workarounds on places like StackOverflow, forums and blogs are lot less forthcoming than for current languages. There is a big benefit in that respect to live with in one of the major eco-systems.


Sony Edakkunnathu
April 17, 2017

re: Creating a Markdown Monster Addin: Save Images to Azure Blob Storage

Great post Rick! We are working with Azure Storage to upload images from our customer facing app. Not sure, we have a use case for this add-in yet.


Pieter van Kampen
April 17, 2017

re: More on ASP.NET Core Running under IIS

Thanks Rick, you mention you can run asp.net core in a virtual, below a static IIS web site. I am looking how to this the other way round:

www.testme.com: asp.net core web site www.testme.com/soap: asmx web services pages

What I have right now, is that the pages under /soap are handled by the asp.net core executable.

Any suggestions?


Derek Licciardi
April 17, 2017

re: Firing an Entity Framework Database Initializer from within DbContext

There's an easy way to solve this specific problem and that is to use schema's in SQL Server. Place each Context into its own Schema and you will get multiple _MigrationHistory tables and multiple views of the model's metadata, each specific to the DbContext that you want to use. If your component doesn't use Code First or won't allow you to move off of the DBO schema, then move your application code from DBO to some other schema and you're all set.


Bill
April 16, 2017

re: .NET 4.5 is an in-place replacement for .NET 4.0

I am baffled why people use .Net

I keep pushing Delphi on comments or forums, not because I have a weird bias but because it seems to be the best tool to use for Windows development and possibly Mobile and Apple as well with their new releases.

.Net is modeled after the productivity of Delphi and the C# language seems to be primarily based on Java with a bit of Delphi sprinkled in (Creator of Delphi created .Net and C#). If you compare .Net and Delphi - the primary difference is not productivity or language features but just the fact that .Net requires a runtime to run and Delphi does not.

Runtime environments add on a ton of extra problems. They add bloat, sluggish and slow startup times, a bazillion files, version issues that prevent your programs from running, complex deployment if you use 3rd party components, no support after X years, support can be yanked if security whole is found in the runtime leaving your program as just a pile of non-executable bits and bytes... I can go on an on but I am at work and need to get things done. I am baffled because native applications do not have issues listed above which runtime environments do, and if you can build a native application then why in the world would you build one that sits on a runtime? Seems like your just asking for problems.

I am not a hater, I am honestly baffled to the bone.

If someone responds to this, please be aware that I said "primary difference" is native. There are differences in the language but they are severely minor compared to Runtime vs Native. The main point I am arguing is Native vs Runtime.


Desmond Mardle
April 16, 2017

re: Publishing and Running ASP.NET Core Applications with IIS

Thanks for this article I have spent a few hours yesterday trying to get my .net core 1.1 website to run on IIS without any luck. This morning I came across your article and it solved my problem straight away. My website is running on Joomla at present. I have been getting to grips with asp.net core the exercise was to convert the existing site to an asp.net core 1.1 which is very near completion. I will publish the new site when finished.

Thanks Desmond6 Mardle


Rick Strahl
April 14, 2017

re: Running .NET Core Apps under Windows Subsystem for Linux (Bash for Windows)

@Matthew, @Jeff - There's also ScriptCs which will allow you to use C# code to automate tasks and also call into .NET components. I believe it works with .NET Core as well now.


Matthew Blott
April 14, 2017

re: Running .NET Core Apps under Windows Subsystem for Linux (Bash for Windows)

@Jeff

You can't do that and I wouldn't expect you to be able to. You can't call objects in Ruby, Python, Java or any other language from bash - it would be like calling .NET objects from the standard Windows terminal. PowerShell is a .NET program itself which is why you're able to interact easily with .NET objects. That said I work pretty much full time with Mono and regularly call C# code from bash (actually zsh but it's much the same thing) with a simple ...


mono app.exe $some_environement_variable

... in my bash scripts. There's nothing to stop you creating an API to expose the methods you want to call and doing the same thing.


Rick Strahl
April 14, 2017

re: Running .NET Core Apps under Windows Subsystem for Linux (Bash for Windows)

@Jeff - No - there's no automation model for this. I don't think you can do this in Powershell with .NET Core either - only classic .NET components. Powershell understands .NET so it can load assemblies, but Bash - not so much, it's a text based interface. So pretty sure the answer to this is no. But didn't I hear that Powershell is being ported to run on Linux? https://github.com/PowerShell/PowerShell @Andrey - I'm not surprised that perf is not all that great. After all WSL is basically an emulator that forwards calls. But this isn't meant as a production feature - it's a developer convenience feature. OTOH, I was testing perf in Docker (with stock Alpine VM in Hyper-V) a few days ago and perf in that scenario is also terrible compared to native Windows. To be fair I didn't optimize anything, but it was pretty sad compared to native, close to what you show here.


Andrey Grishin
April 14, 2017

re: Running .NET Core Apps under Windows Subsystem for Linux (Bash for Windows)

I'm trying this new feature. It works but performance is horribly slow compared to running netcore on Windows.

WSL:

agrishin@AGRISHIN:/mnt/c/Sources/grishin/mytestapp$ time dotnet run
Hello World!

real    0m29.473s
user    0m8.047s
sys     0m27.078s

Git Bash (running with Windows dotnet):

Andrey@AGRISHIN MINGW64 /c/Sources/grishin/mytestapp
$ time dotnet run
Hello World!

real    0m5.600s
user    0m0.015s
sys     0m0.015s

I also tried to edit .cs files with VSCode but again without luck. Editor autocompletion breaks after package restore in WSL. So it looks promising but unusable for now. (I'm using fresh Creators Update Windows)


Jeff Ferguson
April 14, 2017

re: Running .NET Core Apps under Windows Subsystem for Linux (Bash for Windows)

Is it currently possible (or is it on a roadmap) to call into .NET Core assemblies from a Bash script in WSL? In other words, can I develop a Bash script that creates .NET Core objects and calls methods on those objects like I can do to today in Powershell?


Matthew Blott
April 14, 2017

re: Running .NET Core Apps under Windows Subsystem for Linux (Bash for Windows)

I saw your comment under Hanselman's post which piqued my interest - nice write up! I agree Linux can be a bit overwhelming to newcomers - I've been using it regularly for a couple of years now and wish there was something like WSL when I started. As I said in my comment under Hanselman's post, there are a lot of really convenient features built into Linux, it's well worth the effort getting familiar with it.


Rick Strahl
April 14, 2017

re: Running .NET Core Apps under Windows Subsystem for Linux (Bash for Windows)

@Janne - did you install docker from their Web site. I think you might need a full install and follow the install Docker instructions there. I haven't looked at this but will probably over the weekend.


Janne Rantala
April 14, 2017

re: Running .NET Core Apps under Windows Subsystem for Linux (Bash for Windows)

I was also interested to see if I was able to run Docker in WSL. Command "Docker" replied that Docker wasn't found. I don't remember what was the exact error I got, but that was what it was implying. Installing Docker with apt-get however said that docker was already installed. Haven't tried with creator's update yet to see if things have changed though.