locked
Text Captcha works fine on localhost but not on web server RRS feed

  • Question

  • User-440768323 posted

    Hello everyone,

    I am trying to use a custom Text Captcha inside a UpdatePanel. It works fine on localhost, but when I deploy it to the webserver it is not displaying. I am using VS 2010 - vb.net for code and asp.net 4.0 and IIS 6.0 is on the webserver. Here is my code:

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="MessageBoard.aspx.vb" Inherits="ContractApplicationPublic.MessageBoard" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
    <%@Import Namespace="System.Data" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>MWRDGC Contract Application</title>
        <link href="css/xmlMessageBoard.css" rel="stylesheet" type="text/css" />
        <style type="text/css">
            .style2
            {
                color: #69ACD2;
                font-weight: bold;
                border-left-color: #9D9DA1;
                border-right-color: #C0C0C0;
                border-top-color: #9D9DA1;
                border-bottom-color: #C0C0C0;
                padding: 4px;
                background-color: #FFFFFF;
            }
            .style3
            {
                font-size: small;
                font-weight: bold;
                background-color: #FFFFFF;
            }
            .style4
            {
                font-weight: bold;
            }
            .style5
            {
                font-size: small;
            }
            .style6
            {
                color: #3366FF;
                font-weight: bold;
                border-left-color: #9D9DA1;
                border-right-color: #C0C0C0;
                border-top-color: #9D9DA1;
                border-bottom-color: #C0C0C0;
                padding: 4px;
            }
            .style7
            {
                background-color: #FFFFFF;
            }
            .style8
            {
                font-size: small;
                background-color: #FFFFFF;
            }
            .style10
            {
                width: 94px;
            }
            .style11
            {
                width: 100%;
            }
            .style12
            {
                height: 24px;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
            <div id="PageHeading">MWRDGC Contract Question Board</div>
            <br />
            <br />
            
             <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
            
    
            <table class="style11">
                <tr>
                    <td class="style12">
                                <asp:Label ID="Label2" runat="server" ForeColor="#0B73B5"
                                    Text="Contract Number:" Font-Bold="True" Font-Size="Medium"
                            style="text-align: left"></asp:Label>
                                <asp:Label ID="lblContractNumber" runat="server" ForeColor="Black"
                            Font-Size="Medium"></asp:Label>
                            </td>
                </tr>
                <tr>
                    <td>
                                <asp:Label ID="Label3" runat="server" ForeColor="#0B73B5"
                                    Text="Contract Description:" Font-Bold="True" Font-Size="Medium"></asp:Label>
                                <asp:Label ID="lblContractDescription" runat="server" ForeColor="Black"
                            Font-Size="Medium"></asp:Label>
                            </td>
                </tr>
            </table>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            
                <ContentTemplate>
                
                    <div id="CommentForm">
                        <center>
                        <table>
                        <tr>
                            <td valign="top" align="left" class="style10">Your Question:</td>
                            <td>
                                <asp:TextBox ID="txtQuestion" runat="server" Width="350" CssClass="CommentInputBox"
                                    Height="71px" TextMode="MultiLine" />
                            </td>
                        </tr>
                        <tr>
                            <td valign="top" align="left" class="style10">
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td valign="top" align="left" class="style10">
                                &nbsp;</td>
                            <td>
                                <div id="CaptchaLabel">
                                    <asp:Image ID="lblResult" runat="server" ImageUrl="GetImage.aspx" ImageAlign="Left" AlternateText="" />
                                </div>
                                <div id="CaptchaVerify">
                                Verification Number<br />
                                    <asp:TextBox ID="txtCaptcha" runat="server" Width="120" CssClass="CommentInputBox" />
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" colspan="2" class="BottomCell">
                                <asp:Button ID="bttSubmitQuestion" runat="server" Text="Submit Question" OnClick="bttSubmitQuestion_Click"
                                    CssClass="CommentButton"
                                    onclientclick="return confirm('Are you sure you want to SUBMIT the current question?');return false;" />
                            </td>
                        </tr>
                        </table>
                        </center>
                    </div>
                    
                    
                    
                        <asp:DataList ID="DataList1" runat="server"  RepeatLayout="Flow">
                            <ItemTemplate>
                                <span class="style6">Question:</span>
                                <asp:Label ID="PostQuestionLabel" runat="server"
                                    Text='<%# Eval("PostQuestion") %>' />
                                <br />
                                <br />
                                Posted By: User<br />Posted on:
                                <asp:Label ID="PostDateTimeLabel" runat="server"
                                    Text='<%# Eval("PostDateTime") %>' />
                                <br />
                                <asp:Image ID="Image3" runat="server" ForeColor="#0B73B5"
                                    ImageUrl="~/Images/Horizontal_Line.jpg" />
                                <br />
                                <br />
                                <span class="style2">Question Reply:</span>
                                <asp:Label ID="CommentMessageLabel" runat="server"
                                    Text='<%# Eval("CommentMessage") %>' />
                                <br />
                                <br />
                                Posted By: Administrator<br />Posted On:
                                <asp:Label ID="CommentDateTimeLabel" runat="server"
                                    Text='<%# Eval("CommentDateTime") %>' />
                                <br />
                                <br />
                            </ItemTemplate>
                        </asp:DataList>
                   
                    
                    <asp:ScriptManager ID="ScriptManager1" runat="server"
                        EnablePartialRendering="true" />
                   
                                               
                    
                    <asp:Label ID="lblCompanyID" runat="server" Visible="False"></asp:Label>
                    &nbsp;<asp:Label ID="lblContractID" runat="server" Visible="False"></asp:Label>
                   
                    
                    <asp:Label ID="lblUserName" runat="server" Visible="False"></asp:Label>
                   
                    
                </ContentTemplate>
                
            </asp:UpdatePanel>
            
            <asp:UpdateProgress ID="UpdateProgress1" runat="server">
                <ProgressTemplate>
                    <div id="ProgressBar"  style="top: 150px;">
                        <img alt="Loading" src="images/ajax-loader.gif"
                            style="width: 32px; height: 32px" />
                    </div>
                </ProgressTemplate>
            </asp:UpdateProgress>
            
                    &nbsp;</form>
    </body>
    </html>
    Private Function GenerateRandomCode() As String
    
            'Generate a random number for the CAPTCHA image
            Dim s As String = ""
            For i As Integer = 0 To 5
                s = s + Me.rand.Next(10).ToString()
            Next
            Return s
    
        End Function
    
        Public Sub SetCaptcha()
            'Create a new captcha image
            Me.Session("CaptchaImageText") = GenerateRandomCode()
            'append current date to image url to assure loading of new image
            Me.lblResult.ImageUrl = "GetImage.aspx?" + DateTime.Now.ToString()
        End Sub
    
    
    Partial Class GetImage
        Inherits System.Web.UI.Page
        Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            Response.Cache.SetCacheability(HttpCacheability.NoCache)
            'Create a CAPTCHA image using the text stored in the Session object.
            Dim ci As New CaptchaImage.CaptchaImage(Me.Session("CaptchaImageText"), 200, 50, "Century Schoolbook")
    
            Me.Response.Clear()
            Me.Response.ContentType = "image/png"
    
            ci.Image.Save(Me.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
    
            ci.Dispose()
        End Sub
    
    End Class

    also have attached to project a CaptchaImage.dll

     

     

    Wednesday, April 17, 2013 11:35 AM

All replies

  • User-488622176 posted

    Do you see the icon of a missing image, or do you see nothing at all?

    Wednesday, May 1, 2013 3:28 PM
  • User-440768323 posted

    I see the icon of a missing image, sorry for the long time to reply. I didn't recieve an email notification of a post

    Wednesday, June 5, 2013 10:48 AM