-1

I am trying to create a verification email where the user can click on the link but I don't see a way to get the url of the page from code.

I see that

HttpContext.Current.Request.Url.AbsoluteUri;

can be used for the current page but not the verification page that I want to link to.

The code behind for the verification page

protected void Page_Load(object sender, EventArgs e)
{
    string confirm = Request.QueryString("confirm")

    //check the confirm string and verify user
    ...
}
Danson
  • 415
  • 1
  • 7
  • 16
  • [This answer](http://stackoverflow.com/a/7413510/1139830) describes how to get the base web address. Assuming you know the path to the verification page, it's a matter of concatenating the strings (or using the Uri class to do that for you). – mason May 01 '15 at 18:47
  • What is your verification page? – romanoza May 01 '15 at 18:49
  • I was thinking that there is a better way but I will do that if there isn't one. I'm not sure what you mean but it's a page that get a confirmation query string and its path is "~/Pages/Verification" – Danson May 01 '15 at 18:55
  • what roman is asking @Danson is where is the actual code behind meaning your source code ..don't just post a single line of code and expect us to know where in your code you are using it show all relevant code that pertains to your current issue – MethodMan May 01 '15 at 19:05
  • I didn't think it pertains to the problem since my problem is getting the user a link to the page and the verification page doesn't really have anything yet. The page right now get a query string on page load and will confirm that it is correct and mark the user as verified. I edited in what I have in my post. – Danson May 04 '15 at 14:51

1 Answers1

1

You can save the current Url in a ViewState and in your AuthenticationPage, call this ViewState.

In your current page:

 ViewState["PreviousPageUrl"] = HttpContext.Current.Request.Url.AbsoluteUri;

And in AuthenticationPage, you can get the value:

var previousPageUrl = (string)ViewState["PreviousPageUrl"];
Renato Leite
  • 761
  • 1
  • 8
  • 28
  • I want to do it the other way around. I want to get the url of the AuthenticationPage from the current page. – Danson May 01 '15 at 18:49
  • Only possible this way if you create the URL. – Renato Leite May 01 '15 at 18:51
  • @Danson if you know the URL of the AuthenticationPage you can navigate to it from any page within your solution.. are you familiar with how to `Redirect` – MethodMan May 01 '15 at 19:07
  • Yes, I want to get the link so that I can put it in an email to send like in a typical account verification email. – Danson May 04 '15 at 14:34