Last 50 Comments

re: Linq to SQL DataContext Lifetime Management
Today @ 1:43 am | by Dave

Hi
We implemented this functionality into our visual studio solution a while back and have only just noticed that something is not working. Our project uses LINQ to get the info from the database then assigns the properties to public properties within our POCO classes. We can then modify the POCO class properties within our WinForms, then to save the data to the database we re-assign the public properties of the POCO classes back to the LINQ classes to update the database using LINQ. This all works fine however if we have the exact same setup on another computer (computer 2) and click the refresh button on a form on computer 2 (after updating the database on the form on computer 1) the results are not refreshed on the grid on computer 2. The data is somehow being cached. I have an c-sharp example project with one LINQ Class, one POCO class and a database with one table in it which shows this if it is possible to upload it somewhere where someone could perhaps have a look at this or give some advice on this?
Many thanks
Dave
re: ASP.NET 2.0 MasterPages and FindControl()
Saturday @ 9:59 pm | by Rick Strahl

@Nick - that depends. WebForms is amongst the most optimized parts of ASP.NET. If you build tight WebForms (ie. little to no reliance on ViewState) those apps will run faster than MVC apps for example. Talking about slow tech, MVC uses so much dynamic and runtime reflection for inference of types etc. that it has quite a bit of overhead.

All in all the perf difference between the various ASP.NET platforms is relatively small either way though although I totally agree - if you use WebForms the way that most tutorials teach you and using massive third party controls you're quite likely to build a dog of an application. Same is true of other platforms though.

In short, don't spout unsubstantiated crap like that that is totally subjective and dependent on what you actually do in the specific application.
re: ASP.NET 2.0 MasterPages and FindControl()
Saturday @ 6:48 pm | by Nick

Scott Gu says: "One thing we worried about what the performance impact of people mis-using it -- since doing deep walks of the entire control tree lots of time can really slow things down if you don't know what you are doing. "

If anyone was really concerned about performance they wouldn't be using Webforms.
re: Web Browser Control – Specifying the IE Version
Friday @ 2:12 am | by Rainer Euhus

Hi Rick,

Thank you for the information.

Solved a problem with a 'position: fixed' element, which wasn't displayed before I added the registry entry.
re: Publish Individual Files to your Server in Visual Studio 2012.2
Wednesday @ 1:13 pm | by David

Thanks for the responses.

I setup the deploy profile first, but still didn't see the new option.

After poking around a bit more I found this line in the changelog for the update:

"Selective publish – for one or more files you can perform the following actions (after publishing to a Web Deploy endpoint)"

Source - http://www.asp.net/vnext/overview/latest/aspnet-and-web-tools-20122-release-notes-rtw#_Web_Publishing

This makes it sound like it perhaps won't work with an FTP endpoint (which is what I'm using)? Rick, you said it should work with FTP/File transfer though? Have you had this work on your end of things?
re: Publish Individual Files to your Server in Visual Studio 2012.2
May 14, 2013 @ 11:51 am | by Rick Strahl

@Steven - does a full Publish operation work?
re: Publish Individual Files to your Server in Visual Studio 2012.2
May 14, 2013 @ 9:37 am | by Steven Carnes

I am on a MVC4 Application, with File System deployment set up and I still do not have the option. Any clue why?
re: Publish Individual Files to your Server in Visual Studio 2012.2
May 13, 2013 @ 12:01 pm | by Rick Strahl

@David - This all makes sense. I believe you have to have your publish settings configured before you see the individual options since those options do not prompt for profile or settings - they use the current publish profile. So that would explain why you don't see it for the WebAPI project - yet.

The target server does NOT have to have Web Deploy installed to work. You can also use FTP and direct file tranfer (via UNC or network share).
re: Publish Individual Files to your Server in Visual Studio 2012.2
May 13, 2013 @ 8:06 am | by Michael Lang

David,

I have an MVC4 project that it works on, and a Web API project that it does not work on. I have not setup a publish profile for the Web API project yet, but the MVC4 application does publish to Azure. So I presume the menu option requires knowing how to deploy to the target server, which must have Web Deploy 3.0.

Can you setup your Web site project to deploy to Azure, then verify if the menu option works or not. Azure does support Web Deploy 3.0, as that is what I use for my MVC4 web application.
re: Publish Individual Files to your Server in Visual Studio 2012.2
May 10, 2013 @ 5:14 pm | by David

Hm, for some reason this option is not showing up for me.

I'm on VS2012.2, and I'm using a website (not a web project). I have set up the publish option on the actual site, and that seems to be ok. However, if I right click any files in the web site, I don't get the option to upload.

Any clue if this is restricted to just web projects?
re: Publish Individual Files to your Server in Visual Studio 2012.2
May 10, 2013 @ 12:55 pm | by Rick Strahl

@Bryan - I hear you, but I suppose you can always ask to get it installed - that's worked for me in the past. With Web Deploy 3.0 the install is painless and easy for a server now, which I think was a problem previously.

In fact I remember about 2 years ago I was working on a project where we needed to install Web Deploy and it simply didn't seem to work. It was pretty embarrassing :-) We ended up using the FTP deploy which worked but is quite a bit slower. Same location though was able to install Web Deploy 3 last year no issues, so there are definite improvements there.

FWIW, you can still use the publishing features with FTP for those hosts that don't support Web Deploy. It works great too, although in my experience it is a bit slower than Web Deploy.

re: Publish Individual Files to your Server in Visual Studio 2012.2
May 10, 2013 @ 11:11 am | by Bryan

I just wish more hosting companies supported Web Deploy. Since it's an extra installation instead of something that can just be turned on by checking a check box in a site's IIS configuration (or a web.config option) many of the smaller, more economical hosts do not support it.
re: A WebAPI Basic Authentication Authorization Filter
May 07, 2013 @ 4:17 pm | by Joe

Thanks for this article. Question... With Basic Authentication the Request is always made with an Authentication header. That part I get. Does that mean on every request to the Web API we are checking whether or not the username/password combination is valid? Would that be overkill to constantly validate the user?

I have an API Controller that returns data for a Get (GetContacts).
The client is a website and is using Jquery for autocomplete (as someone types in a contact it is calling the GetContacts controller with parameters and returning matching contacts for the autocomplete). The problem is that each request is being authetnicated and is slowing down my autocomplete piece. In fact, with the membership.validateuser method I am getting a deadlock (probably because it updates last login or something like that upon validating the user). I'm not sure of a way around this. Have you experienced this before?
re: Unable to cast transparent proxy to type <type>
May 05, 2013 @ 5:44 pm | by John

Hi Rick,

Thanks for the info. Am currently dealing with this problem now myself but could you clarify how the "AssemblyResolve" handler helps here. As pointed out by "CHOLAN" in your own article here:

http://www.west-wind.com/weblog/posts/2009/Jan/19/Assembly-Loading-across-AppDomains

Your handler is still loading the assembly on the current domain, though CHOLAN's solution to use the new domain doesn't seem to work either (but I'm new to this area so still researching things). Any assistance you can provide would be welcome. Thanks.
re: WCF WS-Security and WSE Nonce Authentication
May 04, 2013 @ 9:40 am | by Charlie

Hi, After spending nights and days on this for a beginner like me,,, I came to the point where I generated a Clientproxyclas using svcutil.exe. And then came to the understanding that I would need some custom bindings to accomodate nonce.. But How do I get to see the Soap XML. The SVClog file just shows some applicationdata and events..
re: A WebAPI Basic Authentication MessageHandler
May 03, 2013 @ 6:18 pm | by Rick Strahl

Yes it works just fine with .NET 4.0.

re: A WebAPI Basic Authentication MessageHandler
May 03, 2013 @ 5:05 am | by Paulo Morgado

@Rick, is the Web API supported on .NET 4.0? I thought it was 4.5 only.
re: A WebAPI Basic Authentication MessageHandler
May 02, 2013 @ 12:54 pm | by Rick Strahl

@Paulo - that's essentially the same code. The await roughly translates into a task.ContinueWith().

If the code is strictly for .NET 4.5 then the await is the way to go, but if also support 4.0 then Task.ContinueWith() is it.
re: A WebAPI Basic Authentication MessageHandler
May 02, 2013 @ 9:11 am | by Paulo Morgado

Rick,

Have you tried something like:

        var response = await base.SendAsync(request, cancellationToken);
 
        if (credentials == null && response.StatusCode == HttpStatusCode.Unauthorized)
                Challenge(request, response);
 
 
        return response;




Instead of:

        return base.SendAsync(request, cancellationToken)
            .ContinueWith(task =>
            {
                var response = task.Result;
                if (credentials == null && response.StatusCode == HttpStatusCode.Unauthorized)
                    Challenge(request, response);
 
 
                return response;
            });

re: Master Page Inheritance and User Controls
April 30, 2013 @ 9:21 am | by asok1421

@squirrl, you just saved my butt. thanks!
re: Problems with opening CHM Help files from Network or Internet
April 29, 2013 @ 11:45 am | by Norman Brenner

Rick: you've saved my life. The .CHM file for AvalonEdit failed in exactly this way, and your wonderful article fixed the problem immediately. Thanks a million!
re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
April 29, 2013 @ 8:14 am | by Joel

"c:\windows\Microsoft.NET\Framework\v4.0.30319\\aspnet_filter.dll"

If you notice in your screenshot it has two slashes between v4.0.30319 and aspnet_filter.dll. After removing one of the slashes it was reported to me that the error no longer occurred.

Also, on your screenshot of the ISAPI Filter screen. You can just right click on the entry and say edit.
re: A WebAPI Basic Authentication Authorization Filter
April 28, 2013 @ 5:19 am | by Dominick Baier

Why would you use an authorization filter for authentication - besides it seems to be the easiest solution....? There are also ordering issues with other (real) authorization filters. Message handlers are a better fit here.

http://leastprivilege.com/2013/04/22/web-api-security-basic-authentication-with-thinktecture-identitymodel-authenticationhandler/
re: A WebAPI Basic Authentication Authorization Filter
April 22, 2013 @ 11:02 pm | by Brad Vincent

Thanks for sharing Rick - could you also please release your token based auth filter on github - or a blog post about it would be great! thanks
re: Linq to SQL DataContext Lifetime Management
April 22, 2013 @ 12:49 pm | by Rick Strahl

@Okan - you should still be able to use HttpContext activation in medium trust. I believe only the thread based activation shouldn't work. Also make sure your context is public - if it's internal it won't work because private reflection is not available in medium trust.
re: Building a better .NET Application Configuration Class - revisited
April 22, 2013 @ 12:46 pm | by Rick Strahl

@Fred - Last week I also updated the NuGet package for Westwind.Utilities 2.0 which includes the new Application Configuration class. Just be aware that the new version is not 100% backwards compatible. The ApplicationConfiguration is the most prominent change - others are refactored classes and namespaces for more logic groupings.

PM > install-package Westwind.Utilities

If you use this package remove the Westwind.Utilities.Configuration assembly.
re: Building a better .NET Application Configuration Class - revisited
April 22, 2013 @ 7:58 am | by Fred Peters

Thanks Rick, it does work for the console application. I'll have to see what's different in my Winforms app.
re: Linq to SQL DataContext Lifetime Management
April 22, 2013 @ 7:26 am | by Okan SARICA

Hi
these context creation is very usefull i think this code not working on trust level medium

i am using a public hosting so this is a restriction for me and i must obey this trust level rule

what do you suggest than ?
re: A WebAPI Basic Authentication Authorization Filter
April 19, 2013 @ 3:21 pm | by Fred Besterwitch

Great article Rick. Very useful for me.

Thanks
re: A WebAPI Basic Authentication Authorization Filter
April 19, 2013 @ 11:54 am | by Rick Strahl

@Danillo - Basic Authentication requires the Authorization header on every request so every request is authenticated, so either the header needs to be there or the challenge is fired every time (as it does unless you pre-authenticate with windows HTTP clients).

I built token based auth for the app described above initially (and I may publish that next), but the customer actually did not want to go with that for this API - it's actually simpler with most HTTP clients to pass the auth credentials instead of tracking a token and inserting it into the header or URL.

Interesting idea though to use basic auth to request UID/PWD through basic auth in the first place though...
re: A WebAPI Basic Authentication Authorization Filter
April 19, 2013 @ 11:31 am | by Danillo Corvalan

Does the client who access this API have to pass this authentication on every request ? Or do you have to implement an access-token-ish way to deal with that ?

Thanks for sharing!
re: A WebAPI Basic Authentication Authorization Filter
April 19, 2013 @ 11:25 am | by Rick Strahl

@David - thanks. Those are good fixes and I've merged them in. Appreciate it - missed the challenge in refactoring :-)
re: Web Browser Control – Specifying the IE Version
April 19, 2013 @ 11:10 am | by Tom Py

Thanks SO much. I just started getting script errors this year in an app I wrote years ago that actually stopped loading data from site when it got the error. With this fix, which I did not see anywhere else through Google, my app loads the flash data properly.
I'm using ie10 in windows 7 and 270f hex worked for me.
Thanks!
re: A WebAPI Basic Authentication Authorization Filter
April 19, 2013 @ 8:29 am | by David Ruttka

Looks like good stuff, thanks for sharing! =) I had a couple of thoughts while reading through it that I felt it was easier to express in code. Here's the pull request https://github.com/RickStrahl/WestwindToolkit/pull/1
re: Handling mshtml Document Events without Mouse lockups
April 18, 2013 @ 2:44 pm | by el dude

BUMP!

I'm facing this challenge but in VB 2008.

It looks like whatever event I add a handler for, all other events become ignored.

A HTML page loads and I hook the onmouseover event. The handler writes everything I mouseover to a list (as an example I found on Microsoft does) but the browser does not respond to anything else (mouse clicks, double clicks, or keystrokes) BUT it does respond to mousewheel actions and the backspace key...

I see that some found success in other implementations... Has anyone found success in VB 2008?
re: An Introduction to ASP.NET Web API
April 18, 2013 @ 11:33 am | by jose

I don't normally comment... But your article helped me a lot. Thanks for writing the article! Read a couple of books but your article clarified a lot of things.
re: Crashing WCF 3.5 JSON Services with DateTime.MinValue
April 18, 2013 @ 2:31 am | by Naveen

Thanks for the article. It helped me a lot. My application was locking itself as you said in the article. I couldn't realize that, it is DateTime data member which caused the issue unless I read this article.
re: WebAPI: Getting Headers, QueryString and Cookie Values
April 16, 2013 @ 5:00 am | by Richard

If request.GetQueryNameValuePairs() can return null, as implied by your GetQueryString method, shouldn't your GetQueryStrings method check for that?
re: WebAPI: Getting Headers, QueryString and Cookie Values
April 16, 2013 @ 3:09 am | by Rick Strahl

@Ross - I'm sure there's some reason to this - most likely it's more efficient than a dictionary and can be streamed. Still it's silly to have to futz around with a clunky interface like this. I think nobody looks and tht and goes right on - it'll throw anybody into a 'WTF do I do with this?' for a few cycles at least.
re: WebAPI: Getting Headers, QueryString and Cookie Values
April 16, 2013 @ 2:14 am | by Ross Smith

Spot on Rick, this has annoyed me too

IEnumerable<KeyValuePair<string,string>> - genius
re: Caveats with the runAllManagedModulesForAllRequests in IIS 7/8
April 15, 2013 @ 12:21 am | by Vladimir

Yep, that is what i was thinking. If I set it runAllManagedModulesForAllRequests to false, event's like PostMapRequestHandler want even trigger for static resources. So that is one option also. Thank you!
re: Caveats with the runAllManagedModulesForAllRequests in IIS 7/8
April 14, 2013 @ 1:05 pm | by Rick Strahl

@Vladimir - you can only see managed handlers and modules. Nothing unmanaged shows up in the pipeline.
re: Caveats with the runAllManagedModulesForAllRequests in IIS 7/8
April 14, 2013 @ 5:07 am | by Vladimir

Hi great article. I have been looking into possibility to deffer my handlers on Post map handler event and i see that for static resources in handler and currentHandler is null. Does this mean that non manged (native) handlers are not visible in asp.net. Is this good way to deffer managed from not manged handlers? Cause i would like to add some logic, but not if it is a static resource.
re: Text Editor Associations/Extensions in Visual Studio getting lost
April 12, 2013 @ 4:45 pm | by Rick Strahl

No definitely not your installation. This is a bug in Visual Studio to this date. It has to do with multiple instances.
re: Text Editor Associations/Extensions in Visual Studio getting lost
April 12, 2013 @ 4:07 pm | by Jorge Mota

I was a web connection user a few years ago, and I always was setting this again and again and again, but I always thought was my installation. :|
re: Hosting the Razor Engine for Templating in Non-Web Applications
April 12, 2013 @ 7:28 am | by Martin

Thanks, Very useful.

I had an issue where stopping the Host wasn't unloading the AppDomain successfully though.

Changing a line in the RazorBaseHostContainer Stop() method to
 RazorEngineFactory<TBaseTemplateType>.UnloadRazorHostInAppDomain();
Seems to have fixed it.

BTW: Is there any technical reason for not allowing Exceptions to bubble up or is this just a design decision?
re: Forcing an ASP.NET Application to 'stay alive'
April 10, 2013 @ 11:11 pm | by Aslam Shareef

Awesome post! Thanks for the ever-useful posts :)
Quick question : My site's connection string relies on the URL of the site. So its essentially a multi-tenant app and I pick up the tenants conn string using the site url. I tried to use PreWarmUp.PreLoad so that the app gets ..well... warmed up even before the first hit comes in. Now the problem is i dont know how to get the current sites URL ... and i cant hit it with a relative path since that would not give me the actual URL and hence the connection string wotn be found.

Any pointers would be appreciated.
re: Passing multiple POST parameters to Web API Controller Methods
April 10, 2013 @ 10:50 am | by Steve

Progress:

Changed AJAX call to a POST.

Changed Route to:

            config.Routes.MapHttpRoute(
                name: "ActionApi",
                routeTemplate: "calc/{controller}/{action}",
                defaults: new 
                { controller = "MWM",
                  action = "CalcMWM"                                  
                }
            );


Added the following to web.config to make Chrome happy:

    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
      </customHeaders>
    </httpProtocol>


CalcMWM() is called, however, get the following in my console log:

"Failed to load resource: the server responded with a status of 405 (Method Not Allowed)."
re: UNC Drive Mapping Failures: Network name cannot be found
April 10, 2013 @ 9:53 am | by Ian G. Lloyd

in XP (for those still stuck in the early 00's like me) you can get to the interface via: Network Connections > Advanced > Advanced Settings > Provider Order... as always Rick thanx...


West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2013