-3

I have an ASP.NET project. Normally if I click search then it shows some results. Now I want after user search, it shows a prompt or window to ask for password first, if user enter the right pwd, it will open the full results, else if user choose not to enter pwd, it open another page which will show only a part of the result.

My plan is to use pwd checking in jsp:

<script src="../../../JS/Registration.js" language="javascript" type="text/javascript"></script>

But I don't know how to check what user choose here then redirect to different pages ?

user1314404
  • 1,253
  • 3
  • 22
  • 51
  • you will have to do that logic on the server side. Check if the password is correct and then redirect accordingly. Checking for correct password in javascript is a very serious security flaw. – Renuka Deshmukh Mar 22 '16 at 02:20
  • So what should be the best way for that purpose ? – user1314404 Mar 22 '16 at 03:23
  • on button click, there will be a postback to the server. Then you should checn if the password is correct, redirect to more-results page, else redirect to less-results page – Renuka Deshmukh Mar 22 '16 at 03:25
  • so the password-checking page is done on C# also ? U have any example, if u have an answer then I can accept that. Tks ! – user1314404 Mar 22 '16 at 03:28
  • Did you searched first before asking? I think you should know how asp.net works before considering asking this kind of question. Also indicate what ASP.NET you are using? MVC? Webforms? – Bon Macalindong Mar 22 '16 at 04:29
  • Yes, I already search some topics, you should also understand that Bon, stop being somebody's father. – user1314404 Mar 22 '16 at 06:07

2 Answers2

1

aspx page

<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<asp:TextBox ID="password" runat="server"></asp:TextBox>

aspx.cs page code-behind

protected void Button1_Click(object sender, EventArgs e)
{
    string pwd = password.Text;
    //write your logic to check pwd and then redirect to other page here
}

let me know if you are still stuck somewhere

Renuka Deshmukh
  • 998
  • 9
  • 16
0

You need to make an ajax call to a C# function which will check the credentials. Then in success field, you can redirect to full results page and error field, specify the url of restricted results. You can look this post how to make an ajax call. I think Palash's answer may be most useful for you

Ajax Call

Community
  • 1
  • 1
It's a trap
  • 1,333
  • 17
  • 39