Friday, 29 August 2014

Copy file(s) from one project to another using post build event…VS2012

When we want to copy one project to another after post Build.

Select the project --> Properties --> Build Events

xcopy $(TargetDir)\*.* C:\inetpub\wwwroot\sitecorelearning\Website\bin\ /r /f /y

Here are some commonly used switches with xcopy:
/I - treat as a directory if copying multiple files
/Q - Do not display the files being copied.
/S - Copy subdirectories unless empty.
/E - Copy empty subdirectories.
/Y - Do not prompt for overwrite of existing files.
/R - Overwrite read only files.

More details can be found 
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true

Recapcha Implementaions

Step1 : Download the Recapcah DLL From

https://code.google.com/p/recaptcha/downloads/list?q=label:aspnetlib-Latest

Add Reference to your solution..

Register assembly on your page

<%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %>

Add Basic Code

 <div>
            <asp:TextBox runat="server" ID="txtname" ValidationGroup="myGroup" />


            <asp:RequiredFieldValidator ID="rfvtxtname" ValidationGroup="myGroup" ControlToValidate="txtname" ErrorMessage="enter data"
                Display="Dynamic" runat="server" />

            <recaptcha:RecaptchaControl
                ID="recaptcha"
                runat="server"
                PublicKey="your key"
                PrivateKey="your key" />


            <asp:Button runat="server" ID="clickMe" Text="Click Me" ValidationGroup="myGroup" OnClick="clickMe_Click" />

            <asp:Label Visible="False" ID="lblResult" runat="server" />

        </div>


The code behind changes are like this


      const string CHALLENGE_FIELD_KEY = "recaptcha_challenge_field";
        const string RESPONSE_FIELD_KEY = "recaptcha_response_field";

        // Getting Proxy for Recaptcha
        if (ConfigurationManager.AppSettings["webProxy"] != null)
        {
            string proxyAdress = ConfigurationManager.AppSettings["webProxy"].ToString();
            if (!string.IsNullOrEmpty(proxyAdress))
            {
                WebProxy webproxy = new WebProxy(proxyAdress);
                recaptcha.Proxy = webproxy;
            }
        }


        var captchaChallengeValue = HttpContext.Current.Request.Form[CHALLENGE_FIELD_KEY];
        var captchaResponseValue = HttpContext.Current.Request.Form[RESPONSE_FIELD_KEY];

        var captchaValidtor = new Recaptcha.RecaptchaValidator
                                  {
                                      PrivateKey = "mykey",
                                      RemoteIP = HttpContext.Current.Request.UserHostAddress,
                                      Challenge = captchaChallengeValue,
                                      Response = captchaResponseValue
                                  };

        var recaptchaResponse = captchaValidtor.Validate();


        var IsValid = recaptchaResponse.IsValid;
        if (!IsValid)
        {
            lblResult.Text = recaptchaResponse.ErrorMessage;
        }

        Page.Validate("myGroup");

        if (Page.IsValid && IsValid)
        {
            lblResult.Text = "You Got It!";
            lblResult.ForeColor = System.Drawing.Color.Green;
        }
        else
        {    
            lblResult.ForeColor = System.Drawing.Color.Red;
        }







Thursday, 28 August 2014

Getting Started With Claim Based Authetication

he realm is the unique identifier of the application -- the identity that's sent to the STS when logging in. However, the audienceUris element is used to limit from what applications the token will be accepted.


Federation metadata

Federation metadata is an XML document that describes the STS: WS-Federation endpoint, which certificate is used to sign the token etc. Most STSs support this document format. The Identity and Access Tool specifies this document in the web.config as follows:







Very Basic Points for Pipeline & Processors


  • Pipelines define a sequence of processors that implement a function
  • Each processor in a pipeline contains a method named Process() that accepts a single argument and returns void.
  • A processor can abort the pipeline, preventing Sitecore from invoking subsequent processors.
  • The type of the argument to the Process() method may be of a type specific to the pipeline or the default Sitecore.Pipelines.PipelineArgs. 
  •  To create a pipeline processor, create a class that implements a method named Process() with the same signature as the other processors in the pipeline.
  •   Your processor can inherit from an existing processor, and you can add, remove, replace and rearrange processors in the pipelines to suit your requirements.
  •   

Thursday, 21 August 2014

Useful Code in order to Remove the Form based authentication Cookie..


       
        private static void ClearFormCookies()
        {
            var context = HttpContext.Current;
            if (context == null || context.Request.Browser == null)
                return;
            var strB = string.Empty;
            if (context.Request.Browser["supportsEmptyStringInCookieValue"] == "false")
                strB = "NoCookie";
            if (context.Request.Cookies[FormsAuthentication.FormsCookieName] != null && string.Compare(context.Request.Cookies[FormsAuthentication.FormsCookieName].Value, strB, System.StringComparison.OrdinalIgnoreCase) != 0)
                context.Request.Cookies[FormsAuthentication.FormsCookieName].Value = strB;
        }

Sitecore Admin Pages Explained

http://firebreaksice.com/sitecore-admin-pages-explained/

/sitecore/admin/cache.aspx

Database Browser

/sitecore/admin/dbbrowser.aspx 

Serialization

/sitecore/admin/serialization.aspx 

Show Config

/sitecore/admin/showconfig.aspx 

Size Status

/sitecore/admin/sizestatus.aspx

Stats


/sitecore/admin/stats.aspx


Unlock Admin

 /sitecore/admin/unlock_admin.aspx

Update Installation Wizard


/sitecore/admin/UpdateInstallationWizard.aspx 

Wednesday, 13 August 2014

Getting Object Null Reference Error while doing Login to Sitecore Sitecore.Web.Authentication.<>c__DisplayClass5.b__2(Ticket ticket) +52



http://briancaos.wordpress.com/2014/06/30/sitecore-web-authentication-c__displayclass5-b__2ticket-ticket-52/

This can happen if you:
  • Run update scripts (it happened for me when updating from Sitecore 7.1 to 7.2)
  • Have 2 Sitecore installations accessing the same database in:
    • Different .NET versions
    • Different Sitecore versions
To solve it, delete any SC_TICKET properties from the CORE database:
1
2
delete from [YourSitecore_Core].[dbo].[Properties]
where [key] = 'SC_TICKET';
Then restart your .NET application, and you should be fine again.

Monday, 11 August 2014

Getting Started With SOLR

Getting Started with Solr


·         Features

o   Hit highlighting
o   Auto correction
o   Faceted Search
o   Multi language support
o   Given Ranked Search Results aka Ranked Retrieval


·         Is
o   No Sql Technology
o   Provide fault tolerance using Solr cloud .
o   Built on Apache Lucene
o   Java Based
o   Open source
o   Need Java Servlet Engine like jetty tomcat jboss
o   Scalable
§  We can distribute indexing and query processing on separate server.
o   Ready to Deploy
o   Optimized          
§  Can handle millions of results
o   Stable
§  Many org still continues with old solr version
§   
o   Text Centric
o   Document Oriented
o   Given Ranked Search Results
o   Provide NRT
o   Read dominant
§  Created once but read multiple times
o   Can be access via http
o   Provides Admin console for Admins
o   Has Huge community of Users
o   rich document (e.g., Word, PDF) handling
o   Created
§  @ CNET Networks
§  When in 2004
§  By Yonik Seeley


·         Is not

o   Data storage or Data processing mechanism
o   Not like web search engine.
o   An alternative or replacement of Relational Sql
o   Provide parent child relation but does not support complex relation
o   Has nothing to deal with SEO
o   Solr can not provide authorization on Search Results
o   Does not provide UI Components for Search output.

·         Keywords

o   NoSQl : Not only Sql
o   NRT : Near Real time
o   SPOF: Single point of failure