About The Author
Michael Flynn is a Web Developer at Terralever, an interactive marketing agency based in Tempe, AZ. He specializes in web technologies that include C# .NET, SQL, XML, AJAX, jQuery, Flash, and also skills in Photoshop and Illustrator. He was been involved in web development since 1998, and earned a Bachelors and Masters degree in Computer Engineering and Computer Science from the Univerisity of Louisville and holds an MSCT certificate in Web Applications.
Calendar
<<  July 2009  >>
SMTWTFS
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

URL Rewriting In Joomla 1.5 on IIS 7

I recently completed a project that needed to have Joomla use SEO friendly URL's on IIS 7.  The main goal was to get this to work with Microsoft URL Rewrite Module for IIS 7.0 Go Live. Doing some research I could not find any tutorials on this, or if anyone had succeeded.  Joomla is PHP based and Apache friendly and I am a .NET Developer so I hope you felt my pain through this learning process.  Joomla has built in SEF (Search Engine Friendly) functionality but works flawlessly on Apache, IIS on the other hand it is a different story.  Joomla uses the htaccess file if the website resides on an Apache server.  IIS doesn't use the htaccess file and therefore can not get the desired results we want.

Joomla Configuration

 

Default Joomla URL


http://www.mydotnetworld.com/index.php?option=com_content&task=view&id=5&Itemid=1

This disadvantage of this url is it is long, hard to read to the human eye, and not search engine friendly, meaning it might never be indexed.

SEF Joomla URL (htaccess disabled)

http://www.mydotnetworld.com/index.php/content/view/5/6/

To enable this you can log into the admin and navigate to Site > Global Configuration.  On the right side you will see a area called "SEO Settings".  Turn "Search Engine Friendly Urls" to on. 

The disadvantage to this approach is it had index.php in the url.  I have read somewhere that it doesn't hurt search engine indexing, which may be true, but if you can fix that for user display it is a must.

SEF Joomla URL (htaccess enabled)

http://www.mydotnetworld.com/content/view/5/6/

If you want to remove the index.php from the URL and you are on Apache you may select the second option under "SEO Settings".  Ignore the warning by "Use Apache mod_rewrite" and turn it on.  I haven't tested this on Apache but it seems to remove the index.php mysteriously as I do not have much knowledge of PHP and how Joomla removes this.  IIS does not have the ability to read the htaccess file, and rewrite rules in it.

SEF Joomla URL with SH404SEF (htaccess enabled)

http://www.mydotnetworld.com/philosophy/marketing/web-strategy

I tried numerous plugins but could not get the desired result I wanted.  The one I finally got working was SH404SEF.  As you can see the above url is much cleaner and easier to read.  This result was accomplished from the above steps.  Yes, even turning on the htaccess option.  When installing this plugin make sure it is enabled.

The last step is to enable the actual rewriting of the page to the correct URL.  I copied the rules from the htaccess file provided by Joomla.  The bold one I could not import into IIS as it could not read the syntax, but works regardless of this rule.  So if anyone has a work around please add a comment.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]


IIS 7 Configuration



I know there are ISASPI filter work around's available but I wanted to see if I could get this to work with the new plugin available for IIS, called Microsoft URL Rewrite Module for IIS 7.0 Go Live

You will need to install the Microsoft URL Rewrite Module for IIS 7.0 Go Live and FastCgi.  Go to your website directory in IIS and make sure you are in features view.  Double click the "URL Rewrite" icon under the IIS section.



Once in the url rewrite section there is an option to "Import rules..." on the sidebar.



Within the textbox that says "Rewrite rules", paste the rules from above that were taken from the htaccess file found in the Joomla base directory. Click apply.  IIS is now set to do URL rewriting for Joomla.



After much searching and reading this is the configuration I came up with to get Joomla to have SEO friendly URL's on IIS 7 and the Go Live Rewrite Module.

Posted on 10/24/2008 1:50:00 AM by cblaze22

Permalink | Comments (1) | Post RSSRSS comment feed |

Categories: Url Rewriting | Joomla | IIS

Tags: , ,

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Use a WCF Service with HTTP and HTTPS in C#

I had a problem with a WCF service that was having problems on a secure page using SSL.  The error said the endpoint could not be found.  I found some resources on making a service HTTPS ready, but not for both.  I finally figured it out that I need two endpoints pointing to the same service.  One endpoing contained another property called "bindingConfiguration" that maps a binding that has a mode of transport which enables an endpoint for https.  The bolded text below is what you need to enable a service for HTTPS.

   

<system.serviceModel>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>

    <behaviors>

        <endpointBehaviors>

            <behavior name="WebServicesBehavior">

                <webHttp/>

            </behavior>

        </endpointBehaviors>

    </behaviors>

    <services>

        <service name="WebService">

            <endpoint binding="webHttpBinding" contract="IWebService" behaviorConfiguration="WebServicesBehavior"/>

            <endpoint binding="webHttpBinding" bindingConfiguration="webBinding" contract="IWebService" behaviorConfiguration="WebServicesBehavior"/>

        </service>

    </services>

    <bindings>

        <webHttpBinding>

            <binding name="webBinding">

                <security mode="Transport">

                    <transport clientCredentialType="None"/>

                </security>

            </binding>

        </webHttpBinding>

    </bindings>

</system.serviceModel>

Posted on 10/18/2008 12:54:00 AM by cblaze22

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: ASP.NET | Development Tips | Tips | WCF

Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Http To Https And Back with a Basepage in ASP.NET C#

I needed to have one page redirect to a https protocol, and when leaving that page go back to the http protocol.  I wanted a easy way that would be handled in one place, but have the ability to be overridden when necessary.  I always create a basepage for all my pages, so I decided to create a method that a page can override.  I have a page called checkout.aspx that needs to have https, so I override the parent class to redirect it to the https page.  If the user leaves the page, they will then be redirected back to http with the basepage implementation.

Basepage.cs

public virtual void SetProtocol()

{

    if (Request.ServerVariables["HTTPS"].ToString().ToLower() == "on")

    {

        string url = string.Format("http://{0}{1}", HttpContext.Current.Request.Url.Authority, Request.RawUrl);

        Response.Redirect(url, true);

    }

}

 

protected override void OnInit(EventArgs e)

{

    SetProtocol();

    base.OnInit(e);

}

 

 

 

Checkout.cs

 

public override void SetProtocol()

{

    if (Request.ServerVariables["HTTPS"].ToString().ToLower() == "off")

    {

        string url = string.Format("{0}/checkout", Utility.RootUrl).Insert(4, "s");

        Response.Redirect(url, true);

    }

}

 

protected void Page_Load(object sender, EventArgs e)

{

    SetProtocol();

}

Posted on 9/25/2008 11:05:00 PM by cblaze22

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: ASP.NET | Development Tips | Tips

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Validation Summary For Multiple User Controls in C# ASP.NET

I was looking for a simple way to have the convenience of self contained controls, but still use a single validation summary.   I created a base class for user controls so code can be reused without repeating it and a property called ValidationGroup that finds all validation controls in the control and assigns the validation group to them.

public class BaseControl : UserControl
{
    public BaseControl()
    {

    }

    public virtual string ValidationGroup
    {
        set
        {
            foreach (Control control in this.Controls)
            {
                if (control is BaseValidator)
                {
                    ((BaseValidator)control).ValidationGroup = value;
                }
            }
        }
    }
}

Below is an example of a validation summary and a user control called address that finds all controls within it to use the validation group of the validation summary.

<asp:ValidationSummary CssClass="validationSummary" runat="server" ID="ValidationSummary"
    ValidationGroup="vgEvent"  /> 

 <uc:Address ID="CalendarAddress" runat="server" ValidationGroup="vgEvent" />

Posted on 9/22/2008 12:44:00 AM by cblaze22

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: ASP.NET | Development Tips | Tips | User Controls

Tags: ,

Currently rated 3.0 by 1 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Open Link From IFrame Into New Window with JQuery

I recently had to open links in an IFrame in a new window.  The problem before was files ilke PDFs and images were opening up in the IFrame with no scrolling.  I wanted a clean, quick solution with JQuery so below is what I came up with. 

$(document).ready(function() {
        $('a').click(function() {
        window.open($(this).attr('href'), 'File', 'fullscreen=yes', 'resizable,scrollbars'); return false;
    });
});

Posted on 9/13/2008 8:03:00 PM by cblaze22

Permalink | Comments (1) | Post RSSRSS comment feed |

Categories: Development Tips | jQuery | Tips

Tags: , ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Universal Root/Base Url

I have tried many ways to get the root/base url of a website.  A static approach to this is to store it in the web.config appsettings section and calling it in code.

<appSettings>
        <add key="RootUrl" value="http://www.mydotnetworld.com"/>
</appSettings>

string rootUrl = ConfigurationManager.AppSettings["RootUrl"];

This isnt convenient when you are working locally and the port number might change.  Another way is to call a method to get the base/root of the website.  I have seen numerous ways to do this and most of them had flaws.  I created my own that I use in every project and hasnt failed me yet.  It works in any development environment.

public static string RootUrl
{
    get
    {
        HttpContext context = HttpContext.Current;
        string executionPath = context.Request.ApplicationPath;
        return string.Format("{0}://{1}{2}", context.Request.Url.Scheme,
                                                                context.Request.Url.Authority,
                                                                executionPath.Length == 1 ? string.Empty : executionPath);
    }
}

I place this function inside a utility class and call it wherever the base/url is needed.  It also comes in handy within javascript.

var rooUrl = <%= Utility.RootUrl %>;

Posted on 8/16/2008 2:14:00 AM by cblaze22

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: ASP.NET | Development Tips

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Export A Website Template In Visual Studio

As a web developer consistency and organization is a key factor in efficient, scalable and maintainable projects.  Visual Studio has a nice little feature called Export Template Wizard that will create templates which future projects can be based upon.  I use this tool to create website structures I use over and over, without searching and adding items at the start of the project or during the website development process.  Everything will be available to me in a consistent structure every project.

Create Website

Creating a reusable template first starts with creating a new website and adding the necessary elements that are used in every project.  I have a seperate folder where I keep this template for later user or adding or deleting items in the future and recreating the template.  This post is using Visual Studio 2008.  Some items used in this template are listed below:

  • robots.txt
  • sitemap.xml
  • web.config
  • web.sitemap
  • global.asax
  • masterpage.master
  • stylesheet.css
  • reset.css
  • forms.css
  • basepage.cs
  • utility.cs
  • cssfriendly.dll

I also included pre-existing folders

  • App_Browsers
  • App_Code
  • App_Data
  • App_Themes
    • Default
      • Images
  • Assets
  • Bin
  • Script

What you include depends on your preference.  If you have any suggestions please leave a comment.

 

Export Template

The next step is to export this template to a zip file for reuse in Visual Studio.   Navigate to 'File' > 'Export Template...'

If this is not available which most likely it isn't, right click at the top of Visual Studio near the menu or toolbars and you get a long list of toolbar selections. 

Select 'Customize...' at the very bottom.  The 'Customize' dialog will appear. 

You should be on the 'Command' tab. 

Select 'File' from the 'Categories' list box. 

Under the 'Commands' listbox select and drag 'Export Template...' to the 'File' menu and drop it anywhere. 

We now can export our website to a reusable template.


Export Template Wizard

A dialog window called 'Export Template Wizard'  will appear to 'Choose Template Type'

Make sure the 'Project template' radio button is selected. 

Next select from the 'From which project would you like to create a template?' dropdown select the template we are going to export from the solution. 

Last select the language you would like this template to be from the 'What language category should this template appear under in the New Project dialog box?' dropdown.

Click 'Next >'.

 Next we need to Select Template Options.

Options include choosing a Template icons, Template name, Template description, Automatically import the template into Visual Studio, and Display an explorer window on the output files folder.

Input your necessary options and click Finish.

Windows explorer will now open to the My Exported Templates folder in windows explorer, displaying a zip file that contains all the files of you website template. 


Import Website Template

After creating our website template we can now put it to use.  Create a new website in Visual Studio.   Look under the heading My Templates for the name of the template you created and click the OK button.  Our website templated is loaded with the structure we want and ready to use by your development team.

Conclusion

Looking at many websites with different stuctures can be very frusturating and at times can be time intensive especially on time sensitive projects.  Visual Studio offers a nice way to counter this by offering the ability to create your own templates without the need of searching for necessary files that are used in every project and remembering where they should go.

Download - Website Template.zip (129.88 kb)

Posted on 8/10/2008 3:18:00 PM by cblaze22

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: Visual Studio

Tags:

Currently rated 5.0 by 5 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5