Surendra Sharma

Surendra Sharma

Search This Blog

Friday, July 31, 2015

How to redirect from specific page of OLD site URL to NEW site URL without writing single line of code

If your client website is already running and you have developed it again with same or different technology.

Once the coding and testing of this new website is complete. What next?
Deploy on server. Make it LIVE.

So there may be some old URL or pages which should be redirected to new website pages.

Good example is if somebody bookmarked the old URL then instead of page not found it should be redirected to new pages.

In simple terms it’s called 301 redirect.

How to achieve 301 redirect without writing code in ASP.NET?

Just make entries in web.config by specifying old URL pages mapping with new pages as below.

Suppose you old page URL is and you want to redirect it to new page as

than your config file entry is

    <location path="contact.php">
        <httpRedirect enabled="true" destination="guest/contact-detail.aspx" httpResponseStatus="Permanent" />
    <location path="license.pdf">
        <httpRedirect enabled="true" destination="newlicense.aspx" httpResponseStatus="Permanent" />

You can specify any numbers of pages here. But this is good for limited pages. My suggestion is that its limit should be upto 50 pages.

If you have more than 50 pages then write the custom redirecting code.

Please leave your comments or share this tip if it’s useful for you.

Thursday, July 30, 2015

How to trigger mail in ExactTarget using C# code

ExactTarget is a cloud service provided by Salesforce for running email campaign for email marketing. 

Here is a code to trigger emails in ExactTarget via its web service.

Change necessary values in below code and call the method. That’s it.

static void TriggerEmail()
    SoapClient client = new SoapClient();
    client.ClientCredentials.UserName.UserName = "xyz";
    client.ClientCredentials.UserName.Password = "xyzpassword";

    //Create a new subscriber - person email id
    Subscriber newSub = new Subscriber();
    newSub.EmailAddress = "";
    newSub.SubscriberKey = "";

    //Create the subscriber attributes
    newSub.Attributes = new ExactTargetClient.Attribute[4];

    //Attribute - First Name
    newSub.Attributes[0] = new ExactTargetClient.Attribute();
    newSub.Attributes[0].Name = "First Name";
    newSub.Attributes[0].Value = "Enter your first Name Here";

    //Attribute - Last Name
    newSub.Attributes[1] = new ExactTargetClient.Attribute();
    newSub.Attributes[1].Name = "Last Name";
    newSub.Attributes[1].Value = "Enter your Last Name Here";

    //Attribute - Zip Code
    newSub.Attributes[2] = new ExactTargetClient.Attribute();
    newSub.Attributes[2].Name = "Zip Code";
    newSub.Attributes[2].Value = "110011";

    //Attribute - State
    newSub.Attributes[3] = new ExactTargetClient.Attribute();
    newSub.Attributes[3].Name = "State";
    newSub.Attributes[3].Value = "Johannesburg";

    //Create a TriggerSend that uses an existing TriggerSendDefinition
    TriggeredSend ts = new TriggeredSend();
    ts.TriggeredSendDefinition = new TriggeredSendDefinition();

    //The external key assigned to the TriggerSendDeinition at ExactTarget
    ts.TriggeredSendDefinition.CustomerKey = "101"; //Keep in config file
    ClientID clientID = new ClientID();
    clientID.ID = 1234567; //Keep in config file
    ts.Client = clientID;

    //Instantiate the CreateOptions object for the create call
    CreateOptions cOptionsTS = new CreateOptions();
    cOptionsTS.RequestType = RequestType.Asynchronous;
    cOptionsTS.RequestTypeSpecified = true;

    ts.Subscribers = new Subscriber[] { newSub };

        //Create the TriggeredSend
        string tsRequestID = "";
        string tsStatus = "";
        CreateResult[] tsResults = client.Create(cOptionsTS, new APIObject[] { ts }, out tsRequestID, out tsStatus);
        TriggeredSendCreateResult tsCreateResults = tsResults[0] as TriggeredSendCreateResult;

        Console.WriteLine("Status Code: " + tsResults[0].StatusCode);
        Console.WriteLine("Status Message: " + tsResults[0].StatusMessage);

        //Check for Error
        if (tsStatus != "OK") { throw new Exception(); }

    catch (Exception exCreate)

Please leave your comments or share this code if it’s useful for you.