Recent Comments



KRDM
Yesterday

re: Strongly Typed Configuration Settings in ASP.NET Core

Saved my bacon. Been fighting this for a few days now. Thanks!

Andrew Lock
Monday

re: Strongly Typed Configuration Settings in ASP.NET Core

@Rick - yeah I agree RE developers needing to explicitly add the IConfiguration, though I guess it's an attempt to drive all access to configuration through strongly typed config classes?

There appear to be a lot of closed issues relating to reloadChanges not working properly cross platform and so being removed, but I haven't dug in to what the state of play is now. Maybe was too difficult to do reliably cross platform so was pulled out, so maybe that overload will disappear too..

Rick Strahl
Monday

re: Strongly Typed Configuration Settings in ASP.NET Core

@Andrew - "reloadOnChange" is not working for me. I haven't checked closely in what scenarios it might work - it's not working when running through IIS express at least.

IConfiguration injection - yeah I had a back and forth on that with David Fowler yesterday. It seems odd to me that this is not available by default without having to explicitly add it to the DI provider. Seems like a pretty crucial component you'd need just about anywhere in the application if you're managing configuration correctly. Oddly IOptions<T> doesn't need anything and it probably depends on IConfiguration to read that data - yet still it's not injectable by default unless you explicitly add it.

The problem I have with that is that if you have sub-components that may depend on configuration, you are dependent on developers explicitly adding IConfiguration somewhere in their service config. If they don't - a sub-component can't get at IConfiguration cause it's simply not registered which is a real sucky situation IMHO.

Andrew Lock
Monday

re: Strongly Typed Configuration Settings in ASP.NET Core

Nice post! Particularly useful point about injecting the IConfiguration. I actually wrote a similar post the other day and missed that as a possibility to access the raw configuration.

I was more focused on the properties of your strongly typed configuration models that don't bind correctly : http://andrewlock.net/how-to-use-the-ioptions-pattern-for-configuration-in-asp-net-core-rc2/

It's interesting that the settings don't refresh automatically - my understanding of the 'reloadOnChange' parameter of AddJsonFile() was that it would do just that! Is that not the case? Or is it just that that only works for this particular FileProvider rather than the whole configuration in general.

Again, great post!

ecesari
Saturday

re: Adding minimal OWIN Identity Authentication to an Existing ASP.NET MVC Application

Hi Rick, thank you for the great article
Do you have idea on how to integrate MVC website with app mobile.
I mean... now I'm able to do external login on the web mvc, I moved some funtions to web api and I0m triyng to connect also using custom (xamarin) APP. what is the correct approach? I want my APP to be logged in to my mvc backend, using google credentials
Do you have any idea?
Thanks so much

Suraj Gharat
May 20, 2016

re: Using plUpload to upload Files with ASP.NET

Awesome article.
Is is possible to do concurrent chunking ?

freedomn-m
May 19, 2016

re: Rendering ASP.NET MVC Views to String

@Vicente Mantrana - the line 'ViewEngines.Engines.FindView' takes masterName as the last argument (null in the code here) - pass your _layout path instead of the null, eg: "~/Views/Shared/_LayoutEmail.cshtml"

steve
May 12, 2016

re: Using Let's Encrypt with IIS on Windows

Can this process work with a hosting site that doesn't allow direct IIS access?

Rick Strahl
May 09, 2016

Eric
May 09, 2016

re: Getting 'motivated' to move to to SSL and HTTPS

"... as well as PowerPoint scripts that let you automate... "

Interesting use of a slide deck, there. ;-)

Seriously though, good article.

Adam Senour
May 09, 2016

re: Windows 10 Upgrade and IIS 503 Errors

First of all, as others have pointed out, this post is AWESOME. This probably saved me about 8-10 hours of guessing horribly at the problem.

One oddity that I noticed in my particular case, and I'm not sure if anyone else has noticed this. I noted the version number of the IIS URL Rewrite module before I uninstalled it, and it was 7.2.2. When I downloaded the newer version of the module from WPI, I noticed that the version number was 7.2.1952. I'm guessing this means that this specific problem was fixed at some point in one of those 1950 builds, although narrowing it down might be tricky!

Anyway, thanks again, Rick!

Eric
May 05, 2016

re: Windows 10 Upgrade and IIS 503 Errors

I was having the same error problem but persistence prevailed!


On Windows 64bit you also need to edit the "Wow6432Node"


"Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp"
"HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\InetStp"


Frustrating little detail....

Rick Strahl
May 05, 2016

re: Web Browser Control – Specifying the IE Version

1.) I think VS 2015 uses a later version - they are using this registry hack as well - DevEnv is one that is listed.
2.) Yes it works on all versions of Windows. The trick is making sure you get the right browser version - at this point go with 11001 always
3.) You can't update the HKLM registry unless you run as admin, but you can upload HKCU key from an application
4.) IE 11 is plenty 'modern' - it does a great job with just about all modern Web content

There are other engines like Awesomian and a few others, but frankly they are all very flakey on WIndows. I have several applications that use Awesonium on my Windows box and they are all broken on my Bootcamp'ed Mac because the Awesomium SDK is apparently broken. The IE control works fine. I have several products that rely heavily on browser automation and these are working without problems with IE based browser controls.

Rick Strahl
May 05, 2016

re: Web Browser Control – Specifying the IE Version

1.) I think VS 2015 uses a later version - they are using this registry hack as well - DevEnv is one that is listed.
2.) Yes it works on all versions of Windows. The trick is making sure you get the right browser version - at this point go with 11001 always
3.) You can't update the HKLM registry unless you run as admin, but you can upload HKCU key from an application
4.) IE 11 is plenty 'modern' - it does a great job with just about all modern Web content

There are other engines like Awesomian and a few others, but frankly they are all very flakey on WIndows. I have several applications that use Awesonium on my Windows box and they are all broken on my Bootcamp'ed Mac because the Awesomium SDK is apparently broken. The IE control works fine. I have several products that rely heavily on browser automation (http://markdownmonster.west-wind.com/ and http://helpbuilder.west-wind.com) and these are working without problems with IE based browser controls.

Rob
May 05, 2016

re: Resetting Entity Framework Migrations to a clean Slate

Hi Rick,

I've appreciate your blog. I've been in this situation a couple of times as well. It's why I don't like code first for large applications. Sure they work wonderfully on little demo type applications. But something seems to go wrong eventually. So I've used both methods to resolve my "bonked" migrations. Good to know I'm not alone.

I do what Tim does when I get to a point where I don't need the migrations anymore. Create a SQL script, initialize a database with that SQL script, and call it a day. So why code first?

James
May 05, 2016

re: Web Browser Control – Specifying the IE Version

Thank you for this informative explanation.

I am new to desktop application development and I have few questions on this topic that I hope you would be able to clarify for me. I am trying to create a simple web browser, no address bar and when the application is opened, it opens directly to a webpage I hardcoded. I am receiving javascript errors and display issues when the page is opened in the application , but not when I open the page in my IE 11 browser. I am assuming its the webbrowser using the old engine that is causing the problem?

1. In Microsoft Visual Studio Community 2015, does the WebBrower still use the IE 7 engine?
2. Would the registry hack you suggest work across Windows 7,8, 10?
3. Wouldn't MS security prevent registry updates from an application?
4. Do you have any suggestion for a different compiler that I could embed a more modern webbrowser/engine into? This would be a Windows desktop application only. No mobile, no Apple.

Thank you for your time.

Jim Casement
May 05, 2016

re: Detecting Text Encoding for StreamReader

Great Post! Still relevant and cured my troubles when processing files from Japan.
I owe you many beers.

Vijay
May 05, 2016

re: Gotcha: Entity Framework gets slow in long Iteration Loops

Thanks for narrating and documenting in a right way

Tom Knowlton
May 03, 2016

re: Adding proper THEAD sections to a GridView

I am wondering if the same solution is available for the DataGrid?

Rick Strahl
May 02, 2016

re: Rebooting Database Localization for ASP.NET with West Wind Globalization 2.0

There's no direct way to automate in a build process, but all the interfaces that perform those tasks are available for you to create a small wrapper. Perhaps you can create a small console app or powershell script that automates the process and lets you build your resources. Maybe open an issue on GitHub so there's a reference for this as a feature request.

Dan
May 02, 2016

re: Rebooting Database Localization for ASP.NET with West Wind Globalization 2.0

Hi Rick

Thanks for the great library. I was wondering if you have any ideas or samples on how to have a build process create the strongly typed classes so we don't have to do create them manually. Since it seems we need context, I have not found a good way to do this.

Thanks in advance...

Cheers

Alex
April 26, 2016

re: Windows 10 Bash Shell Network Connectivity not working?

Thank you, my resolv.conf was empty but just adding a 'nameserver 8.8.8.8' line did the trick.

RK
April 25, 2016

re: UNC Drive Mapping Failures: Network name cannot be found

Worked- Great- Thanks

In my case, Unable to Map any Network drive or Communicate via Script. Even the Provider Tab was missing under advanced. System was infected with malware, but same issue even after cleanup. Populated the Registry keys for Network provider-RDPNP,LanmanWorkstation,webclient.Fixed.

Thanks
RK

Rick Strahl
April 23, 2016

re: Windows 10 Bash Shell Network Connectivity not working?

@Mark - yup found that out as well and got a note from one of the program managers that this has been addressed but the fixes didn't make it into the 14328 build. Hopefully this stuff will show up in the next drops or maintenenace releases.

Mark
April 23, 2016

re: Windows 10 Bash Shell Network Connectivity not working?

Everything you mentioned as broken in 14316 is still broke in 14328. Thanks for the resolv.conf tip, it didn't even exist in my installation I had to create it.

Daniel B
April 22, 2016

re: Using plUpload to upload Files with ASP.NET

Rick, what do you do (or can you do) when attempting to upload images larger than the httpRuntime maxRequestLength set in the web.config (default if unset is 4,096 KB)? If this is not set, or is too low, then any attempts to upload a file over this amount will result in the file _seeming_ to have uploaded (no error thrown, progress bar increments as if the the upload is happening) but the file isn't in the destination folder, because the web server throws the error 400 (bad request) quietly.

I'm tempted to increase the maxRequestLength to some ludicrous-high value, but then that leaves the door open to malicious attempts (DOS). I'd rather let the client set their value, but be informed if they attempt to upload something too large, so they know they need to adjust this value higher, or deal with the upload some other way.

ivar
April 22, 2016

re: "Variable is assigned but its Value is never used" Warning

Did the same thing, thank Google. I thought the compiler is smart, then I thought I am smarter.

bardia
April 18, 2016

re: ClientIDMode in ASP.NET 4.0

is there any solution to clean up 'name' property of control , like this "ctl00$content$txtName" to this "content" ?

Ryanba29
April 18, 2016

re: Web Browser Control – Specifying the IE Version

In c# at least you can specify System.AppDomain.CurrentDomain.FriendlyName.ToString() in place of the executable name. That way you don't have to change your executable name for debug mode.

Kay
April 16, 2016

re: Going Big: 40 Glorious inches of 4k with the Philips BDM4065UC

These are seriously great monitors at the price. Still holding out for the PG348Q here, VA panels give me a headache after awhile.

Mark
April 14, 2016

re: Windows 10 Bash Shell Network Connectivity not working?

Thanks for posting this. I had a different variation of the same problem. I was connected to a VPN when I installed, so my first DNS server was on a network that I was not always connected to.

Gert
April 12, 2016

re: Windows 10 Upgrade and IIS 503 Errors

Thanks. Just upgraded from Windows 8 to 10. Got this same problem and simply repairing the module solved the problem.

Rolando
April 12, 2016

re: Using Let's Encrypt with IIS on Windows

Hello there, so this process (win-simple) is not as easy as it seems. I have attempted numerous times in trying to install the certificate and this is the error I have received. I did go into IIS and moved the static file above the extensionlessurlhandler, so that is correct. The only thing left is the web_config file?? Please help, and let me know if the web config file needs to be updated/corrected, and to what it should be. Thank you very much for your time.

This could be caused by IIS not being setup to handle extensionless static
files. Here's how to fix that:
1. In IIS manager goto Site/Server->Handler Mappings->View Ordered List
2. Move the StaticFile mapping above the ExtensionlessUrlHandler mappings.
(like this http://i.stack.imgur.com/nkvrL.png)
3. If you need to make changes to your web.config file, update the one
at C:\Users\rolando\Desktop\letsencrypt-win-simple.v1.9.0\web_config.xml

Rick Strahl
April 12, 2016

re: Google AdSense for AJAX Content

@JackyWest - yes for Angular I use similar code like that for Google Analytics and that works fine and that code will work globally if you have ads on the page, but only with the first one.

Rick Strahl
April 12, 2016

re: Use IIS Application Initialization for keeping ASP.NET Apps alive

@Eniep - This is an application specific value - I use a custom configuration class to store this URL, but you can use whatever works for your to house that value (AppSettings, static value etc.).

Jackywest
April 12, 2016

re: Google AdSense for AJAX Content

Hi,
I've stumble upon your website many times and I noticed that your really skilled and you know what your doing. I just wanted to say thank you for sharing your solution. I've been searching for that kind of solution for quite a long time. And even i've not tried to implement it yet it's really refreshing to see that we're not alone on this problem.
Google not supporting Ajax and SPA website is a joke to me, why the best tech company in the world would not support his own new trending framework ? And more the using of new web technology... It's not like they don't know we exist !
I find it sad for all programmer who had skill and want to make a few bucks. We built internet everyday and we can't use it for leaving, or with hard times. Anyway that was just my feeling on this quest.

Back to the main subject, I've think of this kind of solution, playing with the request and the URL.
So to summup your solution is to change the URL and Title on each change and fire google ads right after ?
Can we do this on one place like "locationChange" ?

$rootScope.$on('$locationChangeStart', function () {

// update the navigation history/url in addressbar
window.history.pushState({ title: '', URL: href }, "", href);

// fire google ads
(adsbygoogle = window.adsbygoogle || []).push({});
});
Something like that ?

Anyway the fact that your using on your own website is trusting me to use it on my own.
I'll start implementing it today.

Thank you again.

Tristano Ajmone
April 12, 2016

re: Web Browser Control – Specifying the IE Version

GREAT ARTICLE! It was very useful...

Just one CORRECTION:

You mentioned the registry key value "11001 (0x2EDF)", but it should be "11001 (0x2AF9)" instead!

I stumbled on this error while testing this feature inside an app using WebBrowser Control — decimal and hex didn't add up, so I realized it was a typo.

It really works smoothly. Before this hack, I could only use IE4 HTML4 in my apps using the WebBrowser Control... but tweaking the registry as adviced here, resulted in HTML5 + CSS3 pages showing up nicely inside the WebBrowser Control!

I guess the hard part will be to now carry out all the research in order to make sure the app checks out which version of IE is present on the system. There are legion of hacks (from HTML comments to JavaScript) to do that, but most of them are intended for the web. In the context of compiled applications, the checks should be restricted to IE only. If I find a clean solution I'll paste some links/examples here...

Eniep
April 11, 2016

re: Use IIS Application Initialization for keeping ASP.NET Apps alive

Thanks so much for the great post!!! This was exactly what I was looking for. I'm having one small issue though. I can't find
App.AdminConfiguration.MonitorHostUrl
Is there a special namespace I need to import? I'm working on a WebApi2 app.

Thanks again!!!

Rick Strahl
April 10, 2016

re: Using Let's Encrypt with IIS on Windows

@Spongman - you're not going to renew every day. The WinSimple task **checks** every day to see if the cert has expired, but it doesn't renew it every day.

Spongman
April 08, 2016

re: Using Let's Encrypt with IIS on Windows

If you're going to run the renew script every day, why not just have cents that last two days?

Rick Strahl
April 08, 2016

re: Adding minimal OWIN Identity Authentication to an Existing ASP.NET MVC Application

@Joe - OWin is separate from any particular framework, so what's described in this post can be implemented with Web Forms or raw Handlers/Modules. But the operation is optimized for MVC and routed URLs which would make handling non-MVC/Web API applications a more difficult target for this. You'd have to implement custom route handlers most likely to make it work.

The post describes a scenario that doesn't use the default EF identity implementation - it only uses the oWin components but none of the authorization or user management pieces which are deferred for storage in the application.

Rick Strahl
April 07, 2016

re: Configuring ASP.NET and IIS Request Length for POST Data

@Bryce (and several others) - thanks for the reminder that the IIS request filter specifies the value in *bytes* while the ASP.NET httpRuntime value is specified in *kilobytes*. I've updated the post.

Bryce
April 07, 2016

re: Configuring ASP.NET and IIS Request Length for POST Data

It should be noted that "httpRuntime maxRequestLength" is specified in kilobytes and "requestLimits maxAllowedContentLength" is in bytes. If you want the values to be the same, be sure to adjust the numbers accordingly.

Kevin
April 06, 2016

Joe Pool
April 06, 2016

re: Adding minimal OWIN Identity Authentication to an Existing ASP.NET MVC Application

Hi Rick,

I was directed here from the Asp.net forum.

I have an existing ASP.Net web application. It is *not* MVC!

Will (should) the steps here enable my ASP.Net web application to permit my members to log in using OWin or would I run into other problems?

If this is possible, after a member logs in using the OWin process, what would I need to do to match up that login identity to a member in my application's SQL database where I store all of my members by their email address?

Bert Cotton
April 04, 2016

re: Nuget Dependencies and latest Versions

Following up what Rick said, by targeting a specific version and then having NuGet resolve a difference version is very concerning. It removes the ability to guarantee reproducible builds. Building today and targeting 2.54.0 may not have the same result as building tomorrow and targeting 2.54.0, if NuGet pulled in 2.54.1.

This seems backwards from other package management solutions, such as Maven and NodeJS.

It would be helpful if in my project.json I could specify this behavior. Maybe a strict version keyword or something.

Rick Strahl
March 29, 2016

re: Reversing Sort Order on DOM Elements using jQuery

@Mark - yeah that's the beauty of it. You can use whatever sorting logic you want and it's pretty easy to do...

Mark
March 29, 2016

re: Reversing Sort Order on DOM Elements using jQuery

Love it Rick, it also gives you hands on control which can be handy. A simple change like
if (sort.length > sort2.length)
and you are sorting by the length of the list elements. Hope you are well!

Chirag Pathak
March 28, 2016

re: Add a Web Server to your .NET 2.0 app with a few lines of code

Thanks for this great article on BeginGetContext, it really helped me a lot....

Sean Cleaver
March 26, 2016

re: Azure VM Blues: Fighting a losing Performance Battle

Thought it was just me, thank you for the great detailed post. I tried Azure a few years back to host our website and an attempt at a SaaS application. I used WebSites and SQL Azure and a few VM's I found that the site was always going down despite the whole idea that it was always up, the SQL Azure DB's would just fail to connect every now and then and the VM's were just not up to the task. I decided that to use Azure you need to ensure you use multiple servers and zones for everything and replicate your data to get any kind of reliable uptime. This is Waaaaayyy too expensive for small sites. The changes to SQL Azure for DTU based pricing makes SQL really expensive when you start getting a few DB's especially when there tiny.

I moved over to Amazon EC2 and SQL RDS been running for about 18 months like this with no downtime it was far cheaper too with just a t2.small and t2.micro SQL Express Instance the total cost is about the same as 1 Azure VM.

Amazon RDS is great you get a SQL Express instance that you can install multiple small DB's on with automated backups that just runs.

The Desktop under Amazon EC2 is still a little sluggish (I couldn't DEV from it) but nothing like Azure at least you can use it.

Setting up a Private VLan in Amazon is easy, were as in Azure I could not find how to keep my SQL Azure DB's private. You have IP filtering but that's no good with Websites and you can block the internet but doesn't stop anybody with an Azure account.

I have tried Azure again this weekend since I really would like it to work but the VM just feel far too slow you can't do anything from the desktop. So I give up I will stick with Amazon and RDS it's not too expansive and works really well.