0

I'm trying to set membership provider with confirmation email. User is successfully registrated using memb. provider.

After registration, a confirmation email is being sent with userProviderKey which is used to approve user. Link is sent as follows

http://localhost:48992/Account/Verify/e37df60d-b436-4b19-ac73-4343272e10e8

User must click on link sent with key (providerUserKey), problem that is this key does not even show in debug mode as parameter

// in debug providerUserKey is null
public ActionResult Verify(string providerUserKey)
{    
}

What can be the problem?

4 Answers 4

1

If you have the route configuration of Global.asax.cs file as :

          routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional });

You can see it has id parameter as optional. So if the querystring is recognized as id then it will have the value that you have passed.

Change the id to providerUserKey inorder to do the job for you.

      routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{providerUserKey}", // URL with parameters
            new { controller = "Home", action = "Index",providerUserKey=UrlParameter.Optional });

Or Keep the default optional parameter as id and pass providerUserKey as additional querystring parameter.

Say like this:

     @Html.Action("","",new { providerUserKey="e37df60d-b436-" })

Hope it helps

Sign up to request clarification or add additional context in comments.

Comments

1

Try changing the query to

http://localhost:48992/Account/Verify?providerUserKey=e37df60d-b436-4b19-ac73-4343272e10e8

Your ActionResult is looking for this parameter in the URL

1 Comment

Thanks thought it was a post request
1

The Default MVC Route is {Controller}/{Action}/{Id} Hence it recognize it if the parameter name is Id...

Change it to following and it will work.

public ActionResult Verify(string id)
        {    
        }

Still if you don't want to change the parameter name then you can add following routing in your global.asax file and it will work correctly.

routes.MapRoute("MyRouteName","{Controller}/{action}/{providerUserKey}")

You can also pass the default values to it if needed as your path is predefined. Cheers

Comments

1

Unless you've specifed a rule in your global asax your url should look like

http://localhost:48992/Account/Verify?providerUserKey=e37df60d-b436-4b19-ac73-4343272e10e8

if you want to use the above format you need to map a new route in your global.asax

routes.MapRoute(
    // Route name
    "routename",
    // Url with parameters
    "Account/Verify/{providerUserKey}/",
    // Parameter defaults
    new { controller = "Account", action = "Verify" }
    );

1 Comment

Slight bug in the query, no / after the verify

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.