title: Calling url on base of incoming url
body: <p>I am trying to detect incoming url in asp.net page and making some decision on the base of that url But I am facing some problem here is my c# code the detect the url and also condtions</p>
  
  <pre><code>&lt;script runat="server"&gt;
  
      protected void Page_Load(object sender, EventArgs e)
      {
         if (!IsPostBack)
         {
          String url = Request.ServerVariables["HTTP_REFERER"];
          if (url != "http://172.17.0.221:84/CP.aspx")
          {
              Response.Redirect("http://a.sml.com.pk");
          }
          else
          {
              Response.Redirect("http://172.17.0.221:85/MilkSale.aspx");
          }
  
         }        
      }    
  
  &lt;/script&gt;
  </code></pre>
  
  <p>But When I call the page from <a href="http://172.17.0.221:84/CP.aspx" rel="nofollow">http://172.17.0.221:84/CP.aspx</a> then it gives this error:</p>
  
  <blockquote>
    <p>This webpage has a redirect loop.</p>
    
    <p>The webpage at <a href="http://172.17.0.221:85/MilkSale.aspx" rel="nofollow">http://172.17.0.221:85/MilkSale.aspx</a> has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.</p>
  </blockquote>
  
  <p>Can any one tell me what may the error in this code?</p>