Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8450621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:01:07+00:00 2026-06-10T11:01:07+00:00

I am trying to follow the Nancy.Demo.Authentication.Forms example but I am running into problems

  • 0

I am trying to follow the Nancy.Demo.Authentication.Forms example but I am running into problems as it looks like the example code is now out of date. I am sorry if this question is long but I don’t want to miss out my mistakes. So here is what I have done so far:

I successfully installed the authentication package via the package manager console (VS11 beta)

PM> install-package nancy.Authentication.Forms
Attempting to resolve dependency 'Nancy (= 0.10.0)'.
Successfully installed 'Nancy.Authentication.Forms 0.10.0'.
Successfully added 'Nancy.Authentication.Forms 0.10.0' to uMentor.

I wrote an implementation of IUserMapper that takes a dependency on my RavenDB session provider and uses that to find and validate users

public class FormsAuthenticationService : IUserMapper
{
    private readonly IRavenSessionProvider _ravenSessionProvider;

    public FormsAuthenticationService(IRavenSessionProvider ravenSessionProvider)
    {
        _ravenSessionProvider = ravenSessionProvider;
    }

    public IUserIdentity GetUserFromIdentifier(Guid identifier)
    {
        using (var ravenDB = _ravenSessionProvider.GetSession())
        {
            var user = ravenDB.Query<User>().FirstOrDefault(u => u.FormsAuthenticationGuid == identifier);
            return user;
        }
    }

    public static Guid? ValidateUser(IDocumentSession ravenDB, string username, string password)
    {
        var user = ravenDB.Query<User>().FirstOrDefault(u => u.UserName == username && u.Password == password);
        if (user == null)
        {
            return null;
        }
        return user.FormsAuthenticationGuid;
    }
}

I have added a property to my User class to cater for the Guid identifier field required to make the cookie more secure (I have read grumpydev’s posts and understand why this Guid is needed, but is it good practice to make this a property field on the User class?)

public class User : IUserIdentity
{
    public string UserName { get; set; }
    public IEnumerable<string> Claims { get; set; }
    public string Email { get; set; }
    public string Password { get; set; }
    public Guid FormsAuthenticationGuid { get; set; }
}

Finally I have added more setup to my bootstrapper by stealing the code directly out of the Demo (link above). This is where I am getting problems. The code appears to have changed.

public class MyBootstrapper : DefaultNancyBootstrapper
{
    protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
    {
        base.ConfigureRequestContainer(container, context);
        container.Register<IUserMapper, FormsAuthenticationService>();
    }

    protected override void RequestStartup(TinyIoCContainer requestContainer, IPipelines pipelines, NancyContext context)
    {
        var formsAuthConfiguration =
            new FormsAuthenticationConfiguration()
            {
                //These properties do not exist! <<---- Edit - yes they do - see comment 
                RedirectUrl = "~/login",
                UserMapper = requestContainer.Resolve<IUserMapper>(),
            };
        //This method does not exist <<---- Edit - yes they do - see comment
        FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
    }

    protected override NancyInternalConfiguration InternalConfiguration
    {
        get { return NancyInternalConfiguration.WithOverrides(x => x.NancyModuleBuilder = typeof(RavenAwareModuleBuilder)); }
    }
}

EDIT 1
It turns out my mistake was silly (an incorrect using statement – see comments below). All the code above now works just fine so I will leave this question standing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:01:08+00:00Added an answer on June 10, 2026 at 11:01 am

    Just in case you missed the comment above, the answer was pathetically simple:

    Gotcha! OK, I found the problem with the broken code. Resharper
    helpfully put in the following using statement: ‘using
    FormsAuthenticationConfiguration =
    System.Web.Configuration.FormsAuthenticationConfiguration;’. Removing
    this solved the broken code 🙂 However I would still welcome any
    comments about my implementation. I need reassurance that I am on the
    right path.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to follow the steps to compile some C code to import into
I am trying to follow the example here ...but get the exception: 'System.Uri' does
I have been trying to follow mgwt and gwt-phonegap through code.google.com. It feels like
In trying to follow the Android Design Guidelines, I'm running into a small quandary.
Im trying to follow some python code using Ctrl +click, but Im trying to
While trying to follow the python-libmemcached instructions at http://code.google.com/p/python-libmemcached/ I run into trouble at
I am trying to follow the rules and stay RESTful, but I am running
Trying to follow this example. (Section String sorting...) Is there anything obvious that would
Trying to follow the hints laid out here , but she doesn't mention how
Trying to follow some basic examples and getting stuck by this code that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.