Base solution for your next web application

Activities of "joshboilered"

Hello,

I've added a menu item to the AppNavigationProvider called 'Reporting'. Under AppFeatureProvider, I've added a new feature called 'Reporting'. Both the feature in the list of features and the navigation menu are displaying 'Reporting'. I've created a new edition called 'Standard + Reporting'. When I setup a new Tenant, I assign this edition to them.

My question is;

How do I restrict the menu item 'Reporting' from displaying in the Navigation if the Tenant is not assigned to the above edition? Is there a parameter in AppNavigationProvider like there is for permissions? I can't find in the documents how you implement features in the UI, only in the controller. Thanks.

e.g.

.AddItem(new MenuItemDefinition( AppPageNames.Tenant.Reporting, L("Reporting"), url: "App/Reporting/Index", icon: "fa fa-excel-o", requiredPermissionName: AppPermissions.Pages_Tenant_Reporting, requiredFeatureName: AppFeature.Pages_Tenant_Reporting ) )

I'm following the step by step tutorial and understanding everything so far. However, while I like JS modal posts, I'm not a JS expert and usually structure the modal to post the form direct to an MVC controller.

Below is my modification to the tutorial. What I'd like to do is target the MVC controller direct, check model state, then call the ApplicationService to Automap to the domain model to post to the db.

The issue I encounter is that button click event (if no data is filled in the fields)doesn't trigger a validation check based on the ViewModel(CreatePersonInput) and the form doesn't post to the MVC controller.

Index Controller

public ActionResult Index(GetPeopleInput input)
        {
            var peeps = _personAppService.GetPeople(input);
            var model = new PersonListViewModel();
            model.People.AddRange(peeps);
            model.NewPerson = new CreatePersonViewModel();
            return View(model);
        }

ViewModel

public class PersonListViewModel
    {
        public PersonListViewModel()
        {
            People = new List<PersonListDto>();
            NewPerson = new CreatePersonViewModel();
        }

        public List<PersonListDto> People { get; set; }
        public CreatePersonViewModel NewPerson { get; set; }
    }

DTO

[AutoMapTo(typeof(Person))]
    public class CreatePersonInput
    {
        [Required]
        public string Name { get; set; }

        [Required]
        public string LastName { get; set; }

        [EmailAddress]
        public string EmailAddress { get; set; }
    }

INDEX View

@using System.Threading.Tasks
@using TwoZero.Web.Areas.App.Startup
@model TwoZero.Web.Areas.App.Models.PhoneBook.PersonListViewModel

@{
    ViewBag.CurrentPageName = AppPageNames.Tenant.PhoneBook;
}

<div class="row margin-bottom-5">
    <div class="col-xs-12">
        <div class="page-head">
            <div class="page-title">
                <h1>
                    <span>@L("PhoneBook")</span>
                </h1>
            </div>
        </div>
    </div>
    <div class="col-xs-12 text-right ">
        <button class="btn btn-primary blue" data-toggle="modal" data-target="#createPerson"><i class="fa fa-plus"></i> New Person</button>
    </div>
</div>
<div class="portlet light">
    <div class="portlet-body">
        <h3>My Peeps</h3>
        <div class="list-group">
            @foreach (var person in Model.People)
            {
                <a href="javascript:;" class="list-group-item">
                    <h4 class="list-group-item-heading">
                        @person.Name @person.LastName
                    </h4>
                    <p class="list-group-item-text">
                        @person.EmailAddress
                    </p>
                </a>
            }
        </div>
    </div>
</div>


@Html.Partial("_CreatePersonModal", Model.NewPerson);

CREATE MODAL

@model TwoZero.Web.Areas.App.Models.PhoneBook.CreatePersonViewModel


@* Create Modal *@
<div class="modal fade" id="createPerson" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title">
                    <span>Create A Person</span>
                </h4>
            </div>
            <form asp-action="CreatePerson" asp-controller="PhoneBook" method="post" role="form" novalidate class="form-validation">
                <div class="modal-body">
                    <div class="form-group form-md-line-input form-md-floating-label no-hint">
                        <input class="form-control" type="text" asp-for="@Model.Name"  >
                        <label>Name</label>
                    </div>
                    <div class="form-group form-md-line-input form-md-floating-label no-hint">
                        <input type="text" asp-for="@Model.LastName"  class="form-control" >
                        <label>Last Name</label>
                    </div>
                    <div class="form-group form-md-line-input form-md-floating-label no-hint">
                        <input type="email" asp-for="@Model.EmailAddress"  class="form-control">
                        <label>Email</label>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn default close-button" data-dismiss="modal">Cancel</button>
                    <button type="submit" class="btn blue save-button"><i class="fa fa-save"></i> <span>Save</span></button>
                </div>
            </form>
        </div>
    </div>
</div>

Create CONTROLLER

[HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult CreatePerson(PersonListViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var person = vm.NewPerson.MapTo<CreatePersonInput>();

                _personAppService.CreatePerson(person);
            }
            
            return RedirectToAction("Index");
        }

Had a few snags getting a few things setup correctly following the instructions so thought I'd share my 'Getting Started' Step by step "gotcha's" for the next guy not familiar with .net core leveraging .net framework 4.6.1. I'm walking through this now and will update as I run into gotchas not documented.

Enviro setup gotcha's: (or gotme's)

When you download the solution from asp.net zero, you need to do these steps first;

  1. Ensure you have VS2015, update 3 + preview tools
  2. Check the version of your OS and IDE (64 vs 32 bit)
  3. Download the following for your machine environment to aligned to your OS and IDE (I had all the right 64 bit sdk's, but was missing one of the 32 bit) 3.a .net 4.6.1 3.b. .net core 1.1 (earlier versions also needed 1.0.1 in Decemberish version, didn't check if that's changed)
  4. typescript 2

Restart your machine, load Zero and you should be golden to follow the rest of the Getting Started steps.

Step by Step gotchas: (or gotme's)

Although Zero is referencing .Net Framework 4.6.1, its still a .net core application. So you need to use the new localhost db connection string for .net core (if you aren't setting up SQL locally) which has changed since 4.x.

  1. Server=(localdb)\mssqllocaldb; 5.a. Update both connection strings; .web.mvc and .migrator
  2. I had to revert to an older Hangfire version to get it to play nicely.
  3. I'm also finding that if you change the route in Startup.cs to Account/Login, the url's in left nav menu class need to have /Index appended. Haven't figured out why.

TBC... as I dev

Hey Gents,

When I run the app locally, targeting a local db, Signal R works. However, I just recently pushed to Azure web services with a sql db. Everything seems to be working good with the exception of signalR. See attached errors.

Thanks for your help in advance. Josh

Question

Hey Guys,

In a typical .net project, I right click on the web project and publish to azure. However, this is for smaller projects where I haven't followed an NLayered approach. What are the steps to publish all the projects to Azure vs. just Web? I didn't see any documentation for this, thanks.

Hello,

I'm walking through the phonebook tutorial. I'm at this step: Open Windows Command Prompt, locate to the folder containing the .EntityFramework project and run the "dotnet ef migrations add "Added_Persons_Table"

when I run this command, I receive a response stating;

The specified framework 'Microsoft.NETCore.App', version '1.1.0' was not found.

  • Check application dependencies and target a framework version installed at: C:\Program Files\dotnet\shared\Microsoft.NETCore.App
  • The following versions are installed: 1.0.1
  • Alternatively, install the framework version '1.1.0'.

But when I; Install-Package Microsoft.NETCore.App via PM, I receive a message stating that 4.6.1 is not compatible.

Seems like a catch 22... Any suggestions?

I read that some are changing this;

"frameworks": { "net461": { //"Microsoft.NETCore.App": "1.1.0" "Microsoft.NETCore.App": "1.0.0-rc2-3002702" } }

to something more like this;

"frameworks": { "net461": { }, "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.1.0" } } } }

I tired this but it didn't work either.

Tried to run the migrator against;

"Default": "Server(localdb)\mssqllocaldb;Database=ProjectName;Trusted_Connection=True;MultipleActiveResultSets=true"

But received the following error. I don't have SQL so I spun up a quick db in Azure, changed my connection string and re-ran the migrator, same issue.

Any suggestions? Thanks.

Error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling)

at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) ... more sql errors then; Run(Boolean skipConnVerification) in C:\Users\joshr\Documents\Visual Studio 2015\Projects\ProjectName\src\ProjectName.Migrator\MultiTenantMigrateExecuter.cs:line 60

ClientConnectionId:00000000-0000-0000-0000-000000000000

Hey Guys,

I downloaded the .Net Core MPA version, changed the startup proj and ran dotnet restore per your "Get Started" instructions. The project doesn't build, I receive 150 errors right out of the gate. Errors listed below, I did not change the project from what was distributed.

PATH=.\node_modules.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\git C:\Program Files\dotnet\dotnet.exe restore "C:\Visual Studio 2015\Projects\ASPZeroTestProjv2.vs\restore.dg" log : Restoring packages for C:\Visual Studio 2015\Projects\ASPZeroTestProjv2\src\ASPZeroTestProj.Web.Core\project.json... log : Restoring packages for C:\Visual Studio 2015\Projects\ASPZeroTestProjv2\test\ASPZeroTestProj.Tests\project.json... log : Restoring packages for C:\Visual Studio 2015\Projects\ASPZeroTestProjv2\src\ASPZeroTestProj.Core\project.json... log : Restoring packages for C:\Visual Studio 2015\Projects\ASPZeroTestProjv2\src\ASPZeroTestProj.Migrator\project.json... log : Restoring packages for C:\Visual Studio 2015\Projects\ASPZeroTestProjv2\src\ASPZeroTestProj.Web.Host\project.json... log : Restoring packages for C:\Visual Studio 2015\Projects\ASPZeroTestProjv2\src\ASPZeroTestProj.Application\project.json... log : Restoring packages for C:\Visual Studio 2015\Projects\ASPZeroTestProjv2\src\ASPZeroTestProj.Web.Mvc\project.json... error: Unable to resolve 'Abp (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.AutoMapper (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.EntityFramework (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.Zero.Ldap (>= 1.2.0)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.Castle.Log4Net (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Migrator.EF6.Tools (>= 1.0.8)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.EntityFramework (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.AutoMapper (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.Zero.Ldap (>= 1.2.0)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'EPPlus (>= 4.1.0)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'SharpZipLib (>= 0.86.0)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.AutoMapper (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.EntityFramework (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.Zero.Ldap (>= 1.2.0)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Swashbuckle (>= 6.0.0-beta902)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'PaulMiami.AspNetCore.Mvc.Recaptcha (>= 1.1.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Microsoft.AspNetCore.Authentication.JwtBearer (>= 1.1.0)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Microsoft.AspNetCore.Authentication.Facebook (>= 1.1.0)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Microsoft.AspNetCore.Authentication.Google (>= 1.1.0)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Microsoft.AspNetCore.Authentication.MicrosoftAccount (>= 1.1.0)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Microsoft.AspNetCore.Owin (>= 1.1.0)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.AspNetCore (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.HangFire (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.Owin (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.RedisCache (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.Web.SignalR (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.Zero.AspNetCore (>= 1.2.0)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Migrator.EF6.Tools (>= 1.0.8)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.EntityFramework (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'EPPlus (>= 4.1.0)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'SharpZipLib (>= 0.86.0)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.AutoMapper (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.Zero.Ldap (>= 1.2.0)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'dotnet-test-xunit (>= 2.2.0-preview2-build1029)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'xunit (>= 2.2.0-beta2-build3300)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'xunit.extensibility.execution (>= 2.2.0-beta2-build3300)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'xunit.runner.visualstudio (>= 2.2.0-beta2-build1149)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.TestBase (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'EPPlus (>= 4.1.0)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'SharpZipLib (>= 0.86.0)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.AutoMapper (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Migrator.EF6.Tools (>= 1.0.8)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.EntityFramework (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp (>= 1.2.1)' for '.NETFramework,Version=v4.6.1'. error: Unable to resolve 'Abp.Zero.Ldap (>= 1.2.0)' for '.NETFramework,Version=v4.6.1'. ...rinse and repeat for each proj in the solution.

Showing 1 to 8 of 8 entries