0

I have created a simple web site using ASP.Net MVC 4, Internet Application. I added a controller, model and associated views for a new page. Everything works fine running locally, I can register, login and use my new page functionality. After publishing to Azure website I can successfully use the home, about, register, login all of the built in functionality. However I cannot navigate to my new content I added, it gives an error 500. Again all of this functionality does work locally. I am very new to ASP.Net MVC and could use any help I can get.

RouteConfig

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );

Index action of my added controller

private UsersContext uc = new UsersContext();
    private UserProfile user = new UserProfile();
    private Character character = new Character();
    //
    // GET: /Character/

    public ActionResult Index()
    {
        user = uc.UserProfiles.Single(u => u.UserName == User.Identity.Name);
        return View(uc.Characters.ToList().Where(c => c.AccountOwnerId == user.UserId));
    }

Let me know if any other items would help. Oh I put this into my UsersContext instead of in a newly created DbContext.

public UsersContext()
        : base("DefaultConnection")
    {
    }

    public DbSet<UserProfile> UserProfiles { get; set; }
    public DbSet<Character> Characters { get; set; }

EDIT: one thing i forgot to mention is that when i published, it did not add the email address field to userprofile or my entire Character table. I had to run SQL on the Azure manage portal to manually add those items.

4

1 回答 1

1

在试图理解为什么这不起作用之后,我决定重新开始。我从 Azure 以及 SQL DB 中删除了该网站。然后我添加了一个新网站和 SQL DB,然后获取了新的发布设置文件。我将其导入 VS 并发布。这一切都与全新安装一起工作,不确定我第一次搞砸了什么,但它现在按预期工作。谢谢,

于 2013-05-19T18:42:57.737 回答