Click here to Skip to main content
15,905,427 members
Home / Discussions / C#
   

C#

 
GeneralRe: Back with base10, an example code. Hopefully I can exaplain now Pin
stephen.darling16-Sep-10 4:32
stephen.darling16-Sep-10 4:32 
AnswerRe: Back with base10, an example code. Hopefully I can exaplain now Pin
David Skelly15-Sep-10 22:41
David Skelly15-Sep-10 22:41 
GeneralRe: Back with base10, an example code. Hopefully I can exaplain now Pin
Bassam Abdul-Baki16-Sep-10 3:25
professionalBassam Abdul-Baki16-Sep-10 3:25 
GeneralRe: Back with base10, an example code. Hopefully I can exaplain now Pin
David Skelly16-Sep-10 5:58
David Skelly16-Sep-10 5:58 
QuestionTCPIP client server communications Pin
dwolver15-Sep-10 3:03
dwolver15-Sep-10 3:03 
AnswerMessage Closed Pin
15-Sep-10 3:33
stancrm15-Sep-10 3:33 
GeneralRe: TCPIP client server communications Pin
dwolver15-Sep-10 4:34
dwolver15-Sep-10 4:34 
QuestionI'm trying to get a Session and redirect in Globa.asax Pin
luiz sync15-Sep-10 2:13
luiz sync15-Sep-10 2:13 
Good morning folks!


I'm trying to get a Session and redirect the user to another page, but it doesn' work.
If the user doesn't have permission then redirect to root: Default.aspx.
<br />
    private UserStats userStats;<br />
<br />
    protected void Session_Start(object sender, EventArgs e)<br />
    {<br />
        if ((UserStats)Session["UserStats"] != null)<br />
        {<br />
            userStats = (UserStats)Session["UserStats"];<br />
        }<br />
    }<br />
<br />
    protected string PageBasePath<br />
    {<br />
        get<br />
        {<br />
            string basePathString = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Request.ApplicationPath);<br />
            if (!basePathString.EndsWith("/")) basePathString = basePathString + "/";<br />
            return basePathString;<br />
        }<br />
    }<br />
<br />
    protected bool Compare(String x, String y)<br />
    {<br />
        Regex rg = new Regex(y);<br />
        return rg.IsMatch(x);<br />
    }<br />
<br />
    protected void Application_PreRequestHandlerExecute(object sender, EventArgs e)<br />
    {<br />
<br />
        String ExtendsPermissions = "aspx|jpg|png"; <br />
        String page = HttpContext.Current.Request.Path.ToString();         <br />
        try<br />
        {<br />
            String expression = @"(/MYSITE/DIRECTORY/)(([a-zA-Z0-9_\/]+)*)\.(" + ExtendsPermissions + ")$";<br />
            if (Compare(page, expression ) && userStats.Permission.Equals("DIRECTORY") )<br />
            {                <br />
                // Stay in this page!<br />
            }<br />
            else<br />
            {<br />
		// I tried here, but it doesn't work<br />
                //HttpContext.Current.RewritePath("Default.aspx"); // my proble is in some place here.<br />
<br />
		// I tried here too, but it doesn't work too.<br />
                HttpContext.Current.Response.Redirect(PageBasePath); // my proble is in some place here.<br />
<br />
                // to to defalt page root<br />
            }<br />
        }<br />
        catch (Exception ex)<br />
        {<br />
            Response.Write(ex.Message);<br />
        }<br />
    }<br />

AnswerRe: I'm trying to get a Session and redirect in Globa.asax Pin
Calla15-Sep-10 2:42
Calla15-Sep-10 2:42 
Questionsetup and unistall Pin
tomorrow_ft15-Sep-10 2:03
tomorrow_ft15-Sep-10 2:03 
AnswerRe: setup and unistall Pin
Calla15-Sep-10 2:36
Calla15-Sep-10 2:36 
GeneralRe: setup and unistall Pin
tomorrow_ft15-Sep-10 2:48
tomorrow_ft15-Sep-10 2:48 
GeneralRe: setup and unistall Pin
tomorrow_ft15-Sep-10 3:03
tomorrow_ft15-Sep-10 3:03 
GeneralRe: setup and unistall Pin
Calla15-Sep-10 22:47
Calla15-Sep-10 22:47 
GeneralRe: setup and unistall Pin
tomorrow_ft16-Sep-10 1:23
tomorrow_ft16-Sep-10 1:23 
GeneralRe: setup and unistall Pin
Calla16-Sep-10 2:48
Calla16-Sep-10 2:48 
GeneralRe: setup and unistall Pin
tomorrow_ft16-Sep-10 3:24
tomorrow_ft16-Sep-10 3:24 
GeneralRe: setup and unistall Pin
Calla16-Sep-10 3:31
Calla16-Sep-10 3:31 
QuestionEmbedding Dependancies in C# Excel Workbook Pin
Grimes14-Sep-10 23:33
Grimes14-Sep-10 23:33 
QuestionLarge ncb file in a C# project Pin
Bernhard Hiller14-Sep-10 22:14
Bernhard Hiller14-Sep-10 22:14 
AnswerRe: Large ncb file in a C# project Pin
_AnsHUMAN_ 14-Sep-10 22:18
_AnsHUMAN_ 14-Sep-10 22:18 
GeneralRe: Large ncb file in a C# project Pin
Bernhard Hiller15-Sep-10 2:09
Bernhard Hiller15-Sep-10 2:09 
AnswerRe: Large ncb file in a C# project Pin
fjdiewornncalwe16-Sep-10 2:06
professionalfjdiewornncalwe16-Sep-10 2:06 
QuestionThread and Webbrowser Control- Want to Create webbrowser on the fly(runtime) Pin
yogeshcgs14-Sep-10 20:34
yogeshcgs14-Sep-10 20:34 
AnswerRe: Thread and Webbrowser Control- Want to Create webbrowser on the fly(runtime) Pin
Dave Kreskowiak15-Sep-10 2:16
mveDave Kreskowiak15-Sep-10 2:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.