locked
Need help with Show Ad RRS feed

  • Question

  • User-333609119 posted

    I would like for the "respond to ad" links to NOT show when a user isn't logged in. Can someone help me with this please?

    Wednesday, November 5, 2008 7:50 PM

Answers

  • User-333609119 posted
    It seems that everytime I leave a post, I end up figuring out what I needed to do. To fix this problem, I added

    <location path="ShowAd.aspx">

    <system.web>

    <authorization>

    <deny users="?"/>

    </authorization>

    </system.web>

    </location>

    to my web.config file.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 5, 2008 9:05 PM

All replies

  • User-333609119 posted
    It seems that everytime I leave a post, I end up figuring out what I needed to do. To fix this problem, I added

    <location path="ShowAd.aspx">

    <system.web>

    <authorization>

    <deny users="?"/>

    </authorization>

    </system.web>

    </location>

    to my web.config file.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 5, 2008 9:05 PM
  • User-1136540166 posted

    That is a great and simple way to do it.   Visitors to your site can browse and search but they cannot see the classified ad itself.  Depending on the nature of your site, it would either drive people away without looking at any ads, or it would encourage them to register and log in to view the ads.

    In my case, I want visitors to view lots of the ads.   I initialy did what nbrglobalinc showed in the above post.  Then I decided I want to let them look at the ad, but they cannot respond to the ad unless logged in.  

    Now, since they must be logged in, the response email will automatically include their username, email address and the names they gave for first and last name when they registered.  The next best thing I did was set those fields to Readonly=True .   So users will see that the response will have this automatically entered and that they can NOT change it.

    Because the registered username is included in the email, if I get any complaints from those that placed ads, I can very quickly locate the member that sent the spam or whatever and then click "disaprove" and they will never be able to use the site again unless they re-register with a new email address.

    in ShowAd.aspx.vb find the section for the "RespondButton_Click"   and just put in the "IF Then Else" .  If they are not logged in they are sent to the log in page.

    --------------------------------------------------

    Protected Sub RespondButton_Click(ByVal sender As Object, ByVal e As EventArgs)
            If User.Identity.IsAuthenticated Then
                SetActivePanel(ResponsePanel)
            Else
                FormsAuthentication.RedirectToLoginPage()
            End If

    -----------------------------------------------------------------------------------------------------


    Now that we know they are logged in, let's force the username to be added to the email. 

    Also, I added at the bottom of an email a link to the very ad from which the response was generated.  If someone has 100 ads on the site, it  is nice to be able to click the link in the email and see the ad the person is talking about.

    Here is how I added the information to the response email.

    In App_code/BLL/Ads.vb  find this section of the code and add the part of  .Username

    ---------------------------------------------------------------------------------------------------------------

         Public Shared Function SendResponse(ByVal adId As Integer, ByVal senderName As String, ByVal senderAddress As String, ByVal comments As String) As Boolean
                Dim sent As Boolean = False
                Dim s As SiteSettings = SiteSettings.GetSharedSettings()
                Dim ad As AdsDataComponent.AdsRow = GetAdById(adId)
                If Not (ad Is Nothing) Then
                    Dim adUser As MembershipUser = Membership.GetUser(ad.MemberName)
                    If Not (adUser Is Nothing) Then

                        Dim sb As New StringBuilder()
                        sb.AppendFormat("A response to your listing '{0}' at {1}", ad.Title, s.SiteName)
                        sb.AppendLine()

                        sb.AppendLine("The contact information of the user is:")

                        sb.AppendLine(("Registered Username: " + Membership.GetUser().UserName))

                        sb.AppendLine(("Name: " + senderName))
                        sb.AppendLine(("Email: " + senderAddress))

                       
                        sb.AppendLine()

                        sb.AppendLine("User comments/questions:")
                        sb.AppendLine(comments)

                        sb.AppendLine()

                        sb.AppendLine("You can respond to the user by using the email address provided.")
                        sb.AppendLine("If you have sold your item, please log in and unlist your ad.")
                        sb.AppendLine(("Your username is: " + adUser.UserName))    'added by racer184 October 29, 2009
                        'comment out these next 2 lines as they are redundant after I put in the code in the following lines
                        'sb.AppendLine(s.SiteName)
                        'sb.AppendLine(ClassifiedsHttpApplication.SiteUrl)
                        'racer184 adding into the response email a link to the actual ad.
                        'this is helpful to people that have a great number of ads on the site
                        sb.AppendLine("Here is the link to your ad")
                        sb.Append(ClassifiedsHttpApplication.SiteUrl)
                        If Not (ClassifiedsHttpApplication.SiteUrl.EndsWith("/")) Then
                            sb.Append("/")
                        End If
                        sb.Append("ShowAd.aspx?id=")
                        sb.Append(ad.Id.ToString())

     


    Tuesday, November 10, 2009 12:04 PM
  • User730446648 posted

     Just for the record, I agree with racer.

    If User.Identity.IsAuthenticated Then
                SetActivePanel(ResponsePanel)
            Else
                FormsAuthentication.RedirectToLoginPage()
            End If

    Is a much better way to do it.

     

    Or you can use the same if statement to set the panel visibility to true only when the user is authenticated.

     

    Good Luck

     

     

    Tuesday, November 10, 2009 7:47 PM