|
 |
 |
 |
|
Author: |
Travis Whidden |
Created: |
5/13/2007 9:54 PM |
 |
|
Many years I have wanted to post up code examples and things that I have learned. I just have not wanted to write my own blogging software, and I didnt want to use someone elses. |
By Travis Whidden on
6/16/2009 6:05 PM
We have been diving deep into WCF lately. WCF is very nice to use, and a great alternative to web services. One of the things we are doing is dynamic WCF services where services can be created at run time of the web application (highly modified version of BinaryCoder's source listed on the MSDN website). Anyhow, we are making reference to WCF interfaces that are hosted via IIS, and not wanting to generate the dirty proxy code that you need to do with web services. This is a great snippet - the original is: http://blog.weminuche.net/ Our changes were to fit our design, which was a different constructor where we passed the URI of the service, and the receive message size because some of the data results that were passed back were larger then the default window.
/// <summary>
/// Generic Service Proxy for WCF - Connect to a URI/L with a type interface.
/// </summary>
/// <typeparam name="TInterface"></typeparam>
public class ServiceProxy<TInterface> : ClientBase<TInterface>, IDisposable where TInterface : class
{
#region Delegates
public delegate void ServiceProxyDelegate<T>(TInterface proxy);
#endregion
public ServiceProxy()
: base(typeof (TInterface).ToString())
{
}
/// <summary>
/// Pass the URI directly to the constructor.
/// </summary>
/// <param name="uri"></param>
public ServiceProxy(string uri)
: base(new BasicHttpBinding(){MaxReceivedMessageSize = int.MaxValue}, new EndpointAddress(uri))
{
}
public TInterface Proxy
{
get { return Channel; }
}
#region IDisposable Members
public void Dispose()
{
if (State == CommunicationState.Faulted)
{
base.Abort();
}
else
{
try
{
base.Close();
}
catch
{
base.Abort();
}
}
}
#endregion
protected override TInterface CreateChannel()
{
return base.CreateChannel();
}
public static void Call(ServiceProxyDelegate<TInterface> proxyDelegate)
{
Call(proxyDelegate, typeof (TInterface).ToString());
}
public static void Call(ServiceProxyDelegate<TInterface> proxyDelegate, string endpointConfigurationName)
{
var channel = new ChannelFactory<TInterface>(endpointConfigurationName);
try
{
proxyDelegate(channel.CreateChannel());
}
finally
{
if (channel.State == CommunicationState.Faulted)
{
channel.Abort();
}
else
{
try
{
channel.Close();
}
catch
{
channel.Abort();
}
}
}
}
}
Usage is very simple: using (var client = new ServiceProxy<IModuleServices>(someURI))
{
var md = client.Proxy.ModuleDetailsGet(packet.UserSession.SessionID, packet.ModuleInstalledID);
return md.ReturnValue;
}
|
By Travis Whidden on
12/29/2008 10:45 AM
Example of using the ContentControl - it squeezes the content down to its minimum size. I am sure there is a solution, just need to find out how/what

Note, this is just a tester app. I am using the Content Control dynamically in my real application.
|
By Travis Whidden on
1/12/2008 11:18 PM
When I go to open an existing blog, I still get an error Message: Here is the error message I get: I do love how I can embed images into this thing however. That is just amazing! Travis Testing the Open -> Edit -> Save :)
Read More »
|
By Travis Whidden on
1/12/2008 5:08 PM
Its a little buggy. I cant edit any existing posts, but I can post new. I also manage several blogs that exist on this DNN site, and I can use live writer to select between each one of them. 60 bucks is a little expensive for a slice of software that does not work perfectly. Anyhow, We will continue to report bugs.. Hopefully they find a fix for this.
Read More »
|
By Travis Whidden on
9/8/2007 5:19 PM
I decided to throw up some code that I like to use, but hate re-writting. This is how I do some of the dynamic SQL statements. If you think there is a better way of doing it, please let me know. This has worked very well for me so far.
|
By Travis Whidden on
9/8/2007 10:35 AM
I have been involved with web design for many years. Even with 15 years under my belt, I still am amazed when I find something I didn't know. I am not saying I know everything, its just those things that you wish you knew about years and years ago that really get your excitement up.
The other day, I was looking at the HackerSafe code that my company (http://www.amhosting.com) has on its website. I saw the way they put in an image tag and I was like, "what the heck.. they have a bug in their code". Before I went crazy, I decided to look at my live production code and noticed that the way they linked the image was the same in their code they were trying to give me.
So you know what I am talking about... this is what they put in the code:
src="//images.scanalert.com/meter/www.amhosting.com/12.gif"
Notice how src="// part for it. That is where the magic happens
This is why its important. This image is located on my company website: (Secure SSL Mode)
https://www.amhosting.com/MyAccount/UpdateBillingContactInformation/tabid/746/Default.aspx
and the same image code is located on a non https page: (No SSL)
http://www.amhosting.com/Home/tabid/293/Default.aspx
The browser actually knows based on what state your page is on what to call to the remote server. If you didn't have your code like this, it would throw a security error to the end user asking them if they want to show insecure images. Not only does that break credibility, but it also is very annoying between page clicks.
I know this is a very "small" finding, but it is very useful when building ecommerce sites that link to outside content. I hope you are as excited as I am with this very small find.
|
By Travis Whidden on
7/2/2007 4:29 PM
As some of you may know, I recently released a module for DNN that you can use to help redirect your clients to the correct url. This is very handy if you are moving a website to DNN, and dont want to loose your search engine postion links.
I recently updated my code to support tracking hits to yoru pages that result in 404, file not found codes. It increments each time they are entered.
Here is an example of one of my websites I run that used to be written all in asp. (click ot enlarge)

As you can see, this is very good information to have so you dont loose valuable clients coming to your website.
This product can be purchased on SnowCovered for $10 bucks as of today:
http://www.snowcovered.com/Snowcovered2/Default.aspx?tabid=242&PackageID=7640&r=7955725ffc
|
By Travis Whidden on
6/26/2007 10:04 PM
Today I added a 404 redirect module to Snowcovered. This module is very easy to use and extreamly important to anyone who is moving to DNN from their oldschool website.
http://www.snowcovered.com/Snowcovered2/Default.aspx?tabid=242&PackageID=7640&r=7955725ffc
Let me know if you have any questions or need assistance with it.
|
By Travis Whidden on
6/26/2007 9:35 PM
I could not find on DNNs website or on Google a way to configure custom 404 pages inside of DotNetNuke. This was a little frustrating because I just ported over my website with nearly 6000 links (according to Google) and I did not want my viewers to be sent to a page with nothing on it.
So, after thinking about it a little bit, I realized I could do this within IIS specifically for any DNN website.
Create a new web in IIS and point it to your DNN install. This new web will need to be configured with all the proper host headers (and removed from the old DNN website host header list). Once you have it up and running, create your new DNN 404 page. Make it hidden so it does not show up on your menu bar, but is accessible to your visitors.
Get the URL for this page, edit the properties for your new website, and click on the tab "Custom Errors". Find the error code 404, and set the absolute path to it (without the http and the domain name).
Test it and it works great! Example: http://www.badassride.com/thisdoesnotexist
IIS Properties:

Cons: This creates another memory instance of the worker process so it uses more memory on your server. I would recommend only doing this for your portals that request it.
|
By Travis Whidden on
6/26/2007 8:34 PM
I am working on a hand full of projects where I dont want to send people that come in off search engines to 404 pages. So I wrote a module this weekend that will take the 404 info (as seen in my other blog about how to create 404 pages), and redirect them to the correct page, without them even being bothered by a notice telling them the file is not found.
It was a very simple module (as I expected), and so far it looks and works good. Now I just have to do the hard part... create all the redirects. I am thinking I will extend the module to record links that were not handled, so mappings could be easly created for them.
Update: This module is available for purchase on SnowCovered ( http://www.snowcovered.com/Snowcovered2/Default.aspx?tabid=242&PackageID=7640 )
|
|
|
|
|
 |
 |
 |
 |
|
|
|
|