csharpschool / aspnetcorevideo Goto Github PK
View Code? Open in Web Editor NEWCode for the ASP.NET Core 1.1 Book - The First Project
Code for the ASP.NET Core 1.1 Book - The First Project
It says SingOutAsync
instead of SignOutAsync in the paragraph.
Just want to report a minor typo on page 80 of Core 1.1 book.
It says:
Preparing the **Crate** View for Validation
instead of:
Preparing the **Create** View for Validation
I'm wondering why this is not working. It looks exactly like in the book and also your github example. I'm using Microsoft.AspNetCore.Mvc;
`
using Microsoft.AspNetCore.Mvc;
namespace ASPNetCoreVideo.Controllers
{
// attribute routing for MVC
[Route("company/[controller]/[action]")]
public class EmployeeController : Controller // error here....
{
public ContentResult Name( )
{
return Content("John Doe"); // error here....
}
public string Country( )
{
return "United States";
}
public string JobTitle( )
{
return "Web Developer";
}
public string Index( )
{
return "Hello from EmployeeController() class";
}
}
}
`
Error message is
Error | CS0246 | The type or namespace name 'Controller' could not be found (are you missing a using directive or an assembly reference?)
Error | CS0103 | The name 'Content' does not exist in the current context
-- Now, I can get rid of the errors by using System.Web.Mvc but the program doesn't work and the url /company/employee/name does not work and give the correct result. (just an empty page)
/company/employee/country also doesn't work.
but /employee/country works.
So it seems the [Route] is being ignored if I use using System.Web.Mvc
But that's the only way I can get rid of the error messages.
Typo on page 72 'GetEnumSekectList' -- Of course, should be: 'GetEnumSelectList'
I bought the book and am working though it page by page but I am currently stuck in page 94. When I add the migration I get an error shown below.
Unable to create an object of type 'VideoDbContext'. Add an implementation of 'IDesignTimeDbContextFactory' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time.
I also tried running the code downloaded from github and I get the following error from the browser.
An unhandled exception occurred while processing the request.
ArgumentNullException: Value cannot be null.
Parameter name: connectionString
Any assistance is much appreciated. Thank you.
John
A copy/paste error has found it's way into the book on page 21 (22 in paperback).
A new version of the book will uploaded soon.
The code:
public class HardCodedMessageService : IMessageService
{
public string GetMessage()
{
return "Hardcoded message from a service.";
}
}
Should be:
The complete code for the ConfigureServices method:
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IMessageService, HardcodedMessageService>();
}
The complete code for the Configure method:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IMessageService msg)
{
loggerFactory.AddConsole();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.Run(async (context) =>
{
await context.Response.WriteAsync(msg.GetMessage());
});
}
The text:
The Configure method is where you set up the application’s inversion of control container, which will be covered more in the second part of this book.
The second method in the Startup class is ConfigureServices, which is used to configure the application services.
Should be:
In the Configure method, you setup the HTTP request pipeline (the middleware) that is called when the application starts. In the second part of this book, you will add an object-to-object mapper called AutoMapper to this method. AutoMapper transforms objects from one type to another.
The ConfigureServices method is where you set up the services, such as MVC. You can also register your own services and make them ready for DI, for instance the services that you implement using the IMessageService interface at the beginning of the book.
Follow the instructions below if you get the following (or similar) error:
Package 'Microsoft.Extensions.SecretManager.Tools 1.0.1' has a package type 'DotnetCliTool' that is not supported by project 'ASPNetCoreVideo'.
All previous issues have been corrected in the 1.1 book version. The first version of the book does not have a version number inside the book.
You can see the book version under the heading: Book Version inside the book.
Changes when using the ASP.NET Core Web Application (.NET Core) template with the Empty project template.
.NET Core repository: https://github.com/csharpschool/AspNetCoreVideoCore
CHAPTER 3
Implement Routing
Substitute existing text in the section with the following
CHAPTER 7
Adding the HTTP POST Login Action
Two typos have found their way into the book.
Where IMessage is used, substitute with IMessageService. The code here on GitHub is correct for this issue.
The book will be updated with the change soon.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.