Generates a Hyper Link to redirect user to Authentication form

public static string SPUtilGenerateAuthenticationHyperLink(this Page p , string title , string InnerText)
        {

            try
            {
                string url = p.Request.Url.Scheme + "://" + p.Request.Url.Authority + "/_layouts/Authenticate.aspx?Source=" + p.Request.Url.LocalPath;
                string Tag_A = "<a href=\"" + url + "\" title=\""+title+"\">" + InnerText + "</a>";
                return Tag_A;
            }
            catch
            {
                string Tag_A = "<a href=\"#ERROR\" title=\""+title+"\">" + InnerText + "</a>";

                return Tag_A;
            }
            
        }
Example:

 string Tag_A = Page.SPUtilGenerateAuthenticationHyperLink("To Login Click Here", " Here ");
 lit_Msg.Text = "You are not logged in . please log in at first & click " + Tag_A + " to show Authentication Form";

Description

this method generates a Hyper Link to redirect user to Authentication form . gets Titla attribute of tag and inner Text of Tag and generate tag A . then returns user to referrer page .

Details

Double click on the code to select all.

 

;