CodeProject
There are 12 entries for the tag
CodeProject
In it's most basic form, uploading a file or other data to an http form handler using managed code is quite simple using the System.Net.WebClient class.
Listing 1: SimpleWebClientUpload
public void SimpleWebClientUpload()
{
string filePath = Path.GetFullPath("TestFiles/TextFile1.txt");
var client = new WebClient();
client.UploadFile("http://localhost/myhandler.ashx", filePath);
}
It is a common case that some cookies need to be maintained between requests or perhaps a header needs to be added to the request. This is possible using the WebClient class but the technique is not immediately obvious.
The trick is to create a class that inherits WebClient ...
UPDATE: This post is valid as reference information, but an improved version of the code presented can be found here.
While I generally use CassiniDev for smoke testing, sometimes a quick and simple way to run some tests against a site using the built in server comes in handy.
Spinning up an instance of WebDev.WebServer.exe is fairly simple.
The executable can be found at C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.exe (Program Files (x86) for x64 Windows).
If you invoke the .exe with no arguments you will see the usage document listed below.
Listing 1: WebDev.WebServer Usage
---------------------------
ASP.NET Development Server
---------------------------
ASP.NET Development Server Usage:
WebDev.WebServer /port:<port number> /path:<physical path> [/vpath:<virtual path>]
port number:
[Optional] An...
UPDATE: I just found this - http://code.google.com/p/dxcorecommunityplugins/wiki/CR_ReSharperCompatibility
Will report when testing completed.
--------------------
This is how I configure CodeRush/Refactor Pro and Resharper to enable peaceful coexistance.
Even as the feature sets of CR/RF and R# are steadily converging it seems to me that each product has a definite and divergent gestalt.
While evaluation of features is a subjective matter, having the option to use both tools concurrently, choosing the features that make sense to the individual seems to be a win/win situation.
In the not-so-distant past this has been a proposition that involved much fine tuning and a bit of uncertaintly that left all but the most...
Download the sample source code for this post here
In this post I will attempt to describe what I learned while working out how to separate the concerns of a WCF service layer from those of a presentation layer and vice-versa while using a redistributable client assembly and NOT using client proxy code generated by Visual Studio 'Add Service Reference' or svcutil.exe.
The code and scenarios do not necessarily represent best practices and will most likely offend some purists but I do believe that the topics covered represent real world challenges and may provide some insight into some not-so-obvious aspects of...
Code blocks in a T4 template are run in the context of the templating service and have no notion of app/web config.
Oleg Sych provides much detail on T4 Architecture.
To access configuration files in a template we have to drill down a few levels of abstraction to get a reference to the project hosting the template. From that point we can utilize classes from the Configuration namespace to closely approximate standard Configuration file behavior.
Presented here is a re-usable template, ConfigurationAccessor.tt, that can be included in a template to provide strongly typed access to the configuration file and hosting project, and...
I am working on a spike that requires fetching metadata views from Sql Server's sys and INFORMATION_SCHEMA schemas. Initially, coding a few DTO by hand was no problem but as new views are required it obviously became tedious and typo prone.
I really did not want to break out ANY ORM, I just needed to read the data and a simple reflective filler would do just fine. In any case, I found myself in a query window writing a SQL based DTO generator. It ultimately ended up including a lot of clever functionality and I will present it here but first lets start with...
Conventional strategies for reading both StandardOut and StandardError involve helper methods and state objects similar to Listing 1
Listing 1: How it has been done:
public static void RunProcessConventional(string command, string args)
{
var proc = new Process
{
StartInfo =
...
download source code
download this article in .doc format.
Overview
In a recent article I presented a simple implementation of a generic type system in JavaScript. Please see that document for a detailed enumeration of the motivations and benefits, including type safetly and Visual Studio intellisense support.
In this document I will present a 'better' implementation that eliminates many of the limitations of my 'simple' generic type implementation.
I will also provide a starter library of generic compatible collections including Queue, ListArray and Dictionary that you may use immediately and that can serve as a reference for implementing your own generic types in JavaScript.
Features:
...
download source code and demo
download this article in .doc format
Overview
I a previous article I complained about the lack of a true 403 Forbidden error in ASP.NET and the clumsy way that authentication is handled by FormsAuthenticationModule.
The solution I came up with was a good first attempt but, in my opinion, came up short. Particularly when handling authentication of requests that ScriptModule touches. So I decided to take another swing at it, this time with some ammunition.
I took the list of HttpModules from the root Web.config and the ScriptModule that is added to ASP.NET 3.5 web apps and dove in with...
download this document in .doc form
HttpApplication Events, the HttpModules that handle them and in what order:
It is a generally held opinion that to depend upon the order of module/event execution is bad practice and produces brittle code. I agree somewhat with the spirit of the opinion but not at all with the explicit reason.
Events and Collections are not magic bags that arbitrarily insert handlers/items in some random order. I think, in a general sense, that to depend on event handler execution order is a 'bad idea' is valid. In a more specific context, in which the enviroment is known and...
download sample code
Overview
The Microsoft ASP.NET AJAX platform, known previously as ATLAS and ASP.NET 2.0 AJAX Extensions and fully rolled into ASP.NET 3.5, offers rich functionality but in certain scenarios the the required .ASPX client page and ScriptManager control coupled with the Microsoft Ajax library may conflict with existing requirements or present unnecessary overhead.
This document will illustrate that it is possible to leverage the full power of the ASP.NET platform from client script with just a few lines of javascript code on an HTML page.
Caveats:
This document will not attempt to illustrate a robust...
source and demo
What are 'generic types'?
A generic type is defined using one or more type variables and has one or more methods that use a type variable as a placeholder for an argument or return type. For example, the type java.util.List<E> is a generic type: a list that holds elements of some type represented by the placeholder E. This type has a method named add(), declared to take an argument of type E, and a method named get(), declared to return a value of type E. source
Why attempt this in JavaScript?
My answer is two-fold. Primarily for type safety. While the...