Posts

Showing posts from March, 2014

Windows Authentication Still Broken When Using Safari in iOS 7.1

When Apple released iOS 7 last fall, Windows Authentication no longer worked when using Safari. And even though they've released a few updates to the operating system since then, Windows Authentication is still broken when using Safari (Chrome on iOS was unaffected and has been working fine in iOS 7). This seems to just affect requests made from client-script, as making a request to a website that uses Windows Authentication still prompts you for your credentials and works fine for any non-AJAX requests.
Here are two lines from an IIS log showing the same request. The first is from a Safari on iPad and was unsuccessful, the second is from Chrome on iPad and worked fine. Notice the 401 response on the unsuccessful request, due to the missing username (which is visible in the 2ndrequest). The IP address has been obfuscated for these examples.
Unsuccessful (username missing):  2014-03-20 15:38:01 172.26.xxx.xxx POST /Orders/UploadAttachment/2 - 80 - 172.26.152.222 Mozilla/5.0+(iPad;+C…

Funny MVC Routing Quirk

I recently ran into a funny quirk with ASP.NET MVC’s routing. I have a method to retrieve attachments which have been uploaded for orders in an ordering system. Originally, I had the method and the route defined like this:
Method signature: publicActionResult AttachmentView(int orderId, string filename)
Route definition:             routes.MapRoute(name: "Orders_AttachmentView",                 url: "Orders/AttachmentView/{orderId}/{filename}",                 defaults: new { controller = "Orders", action = "AttachmentView" }             );
When I tried to call this method, I’d get an error from IIS saying that the resource wasn’t found. I checked and double-checked the route: no problems, everything was correct. I put a breakpoint in the method to ensure that the code wasn’t being reached, and it wasn’t.
Then I thought that maybe the extension on the filename parameter was throwing the route off. I changed the method signature and route definition …

More Retro Goodness

Image
I hadn't been born when either of these breakfast cereals debuted, yet I still get a kick out of the recent retro packaging for these two. 

Don't Do This With Microsoft's Unity IoC Container

I recently did something pretty dumb when using Microsoft's Unity IoC container. Because one of my classes depended on a string parameter for its constructor (a configuration value that I pass into it), I had to register the type rather than simply relying on dependency chaining. See below (this code is an example of the real code, but not the actual code as to protect my employer's intellectual property guidelines):

.RegisterType<IProjectRepository, ProjectRepository>( newInjectionConstructor( newResolvedParameter(typeof(IRESTServiceHelpers)), ConfigurationManager.AppSettings["CentralServiceURL"], newResolvedParameter(typeof(ICacheManager)), newWidgetFactory()))

See the problem? It's that "new WidgetFactory()" statement. The real class in question didn't implement an interface, so, like a dummy, I set it up to be injected by Unity as shown above.

Mistake!!!

What the code above ends up doing is maintaining a single, new WidgetFactory object that it…