This tutorial shows the implementation of Razor Pages in Asp.Net Core 2. However, when I run my CLI command:
dotnet aspnet-codegenerator razorpage -m PatReg -dc ArtCoreDbContext
-udl -outDir Pages\--referenceScriptLibraries
The output looks like below
I have the following ref-packages in my project.cs,
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview2-final" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Tools" Version="1.1.0-preview4-final" />
<PackageReference Include="Microsoft.Composition" Version="1.0.31" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0-preview2-final" />
<PackageReference Include="NETStandard.Library" Version="2.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Sendgrid" Version="9.8.0" />
<PackageReference Include="ASPSMS" Version="0.0.2" />
<PackageReference Include="System.Composition" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0-preview2-final" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0-preview2-final" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-preview2-final" />
</ItemGroup>
Am I missing a reference?
Indeed I was missing a reference.
I updated all packages and added
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
</ItemGroup>
Final .csproj looks like
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
<UserSecretsId>--------------------------</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.Composition" Version="1.0.31" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0-preview2-final" />
</ItemGroup>
</Project>
At the project folder, run the following two commands.
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet build
Reference: https://gavilan.blog/2018/04/28/asp-net-core-2-doing-scaffolding-with-dotnet-cli-aspnet-codegenerator/
Related
I'm testing a deployed Azure web app using Firefox latest. I am using developer tools and keep finding the following message:
POST https://westus-0.in.applicationinsights.azure.com//v2/track [HTTP/2 400 Bad Request 1542ms]
But I am not using Azure Application Insights. I have done so during development. But I don't have this service enabled in any resource group of my Azure subscription now. The app is performing well. This is the only 'error' that I am getting.
This shows in Chrome (latest) developer tools:
Given that I'm new to this. Can anyone explain this output? I find the 1542ms a little concerning. If this request is being made regularly then will this slow down the app operations? I've got database functionality for logging in and storing data.
I haven't been able to find anyone else who has posted about this kind of thing.
Adding project file details here (with edits)
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>aspnet-rollbase-6D7D2449-EB25-45CE-A8D3-EDAB69CDCAB3</UserSecretsId>
<RootNamespace></RootNamespace>
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
<AssemblyName />
<PackageId />
<EnableNETAnalyzers>false</EnableNETAnalyzers>
</PropertyGroup>
// many Removes here
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.5.0" />
<PackageReference Include="bootstrap" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="5.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="5.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="4.5.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\ServiceDependencies\" />
</ItemGroup>
<ItemGroup>
<None Include="Views\Entries\Create.cshtml" />
<None Include="Views\Entries\Delete.cshtml" />
<None Include="Views\Entries\Details.cshtml" />
<None Include="Views\Entries\Edit.cshtml" />
<None Include="Views\Entries\Index.cshtml" />
</ItemGroup>
</Project>
I have a simple .Net Core project with the following .csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<DebugType>full</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="bootstrap" Version="4.3.1" />
<PackageReference Include="Font.Awesome" Version="5.9.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.CookiePolicy" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Session" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.4" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.2.4" />
</ItemGroup>
As you can see, it contains Bootstrap. And it works nice with Bootstrap. I can see it in my wwwroot folder after restoring project:
But what about Font-Awesome? I don't see the sources of the library after restoring the project. So, I have a question: how I can include Font-Awesome to my _Layout.cshtml file?
P.S
I've found Font-Awesome here:
But I don't understand how I can use it for this place.
If you install the package, you can find the package files in
C:/Users/Your Current User/.nuget/packages/font.awesome.
Inside the "content" dir, there are all the files and they can be manaully imported into the project wwwroot folder to be used like other static files.
I'm moving a project (and database) from Windows and SQL Server and Visual Studio, over to Linux Mint, MySQL and MonoDevelop. I'm most of the way done--but I can't get the type provider for MySQL to work. The most obvious sticking point seems to be that:
open FSharp.Data.Sql
Gives Error, the namespace of 'Sql' is not defined. (And I don't see a NuGet package for that name.)
There's no error on any of:
open MySql.Data
open MySqlConnector
open FSharp.Data
I seem to have packages/references to:
MySqlConnector
MySql.Data
FSharp.Data
FSharp.Data.SqlClient
FSharp.Data.TypeProviders
And then I also get an error for:
SqlDataProvider
"The type 'SqlDataProvider' is not defined'".
I'm sure this is very simple, but I'm not great at which or how to use references--sorry and thanks.
(And I don't really understand how to distinguish SQLProvider from FSharp.Data.Sql provider from MySql.Data.dll from MySqlConnector.dll...)
Edits: Thanks for questions. I assume this is .Net Framework, not Core. The project originated in defaults Visual Studio templates about 3 years ago, and I've never done anything to purse Core.
For the fsproj file(s)--I'm not sure what's what. I have 4 projects in the solution (only 2 actively being used). For the project with the type provider types, this is the project.fsproj.FileListAbsolute.txt, in /obj/Debug.
C:/Users/gen/Desktop/Simulations/SqlFunctions/bin/Debug/Library3.XML
C:/Users/gen/Desktop/Simulations/SqlFunctions/bin/Debug/Library3.exe
C:/Users/gen/Desktop/Simulations/SqlFunctions/bin/Debug/Library3.pdb
C:/Users/gen/Desktop/Simulations/SqlFunctions/bin/Debug/FSharp.Core.dll
C:/Users/gen/Desktop/Simulations/SqlFunctions/bin/Debug/FSharp.Data.TypeProviders.dll
C:/Users/gen/Desktop/Simulations/SqlFunctions/bin/Debug/FSharp.Core.xml
C:/Users/gen/Desktop/Simulations/SqlFunctions/bin/Debug/FSharp.Data.TypeProviders.xml
C:/Users/gen/Desktop/Simulations/SqlFunctions/obj/Debug/Library3.exe
C:/Users/gen/Desktop/Simulations/SqlFunctions/obj/Debug/Library3.pdb
/home/gen/Downloads/Simulations 2018-07-29/SqlFunctions/bin/Debug/Library3.XML
/home/gen/Downloads/Simulations 2018-07-29/SqlFunctions/obj/Debug/SqlFunctions.fsprojResolveAssemblyReference.cache
/home/gen/Downloads/Simulations 2018-07-29/SqlFunctions/obj/Debug/Library3.exe
/home/gen/Downloads/Simulations 2018-07-29/SqlFunctions/obj/Debug/Library3.pdb
The top half of those look like old Windows references-? Obviously none of it includes anything like MySql.Data--which does appear in project/References/From Packages.
Oh wait, this at the solution level may be more relevant (I've never worked with .fsproj files):
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>397e58f9-3730-4c45-a36f-7c9f64d94f1d</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Simulations</RootNamespace>
<AssemblyName>Simulations</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Name>Simulations</Name>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Debug\Simulations.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Release\Simulations.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
</PropertyGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '11.0'">
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>
<Import Project="$(FSharpTargetsPath)" />
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="1a.fs" />
<Compile Include="2a.fs" />
<Compile Include="2b.fs" />
<Compile Include="2c.fs" />
<Compile Include="2d.fs" />
<Compile Include="2e.fs" />
<Compile Include="2f.fs" />
<Compile Include="3a.fs" />
<Compile Include="3b.fs" />
<Compile Include="3c.fs" />
<Compile Include="3d.fs" />
<Compile Include="4a.fs" />
<Compile Include="4b.fs" />
<Compile Include="4c.fs" />
<Compile Include="5a.fs" />
<Compile Include="5b.fs" />
<Compile Include="5c.fs" />
<Compile Include="5d.fs" />
<Compile Include="5e.fs" />
<Compile Include="6a.fs" />
<Compile Include="6b.fs" />
<Compile Include="7a.fs" />
<None Include="Script.fsx" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.Linq" />
<Reference Include="System.Numerics" />
<Reference Include="FSharp.Core">
<HintPath>packages\FSharp.Core.4.5.2\lib\net45\FSharp.Core.dll</HintPath>
</Reference>
<Reference Include="FSharp.Data.TypeProviders">
<HintPath>packages\FSharp.Data.TypeProviders.5.0.0.6\lib\net40\FSharp.Data.TypeProviders.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple">
<HintPath>packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="SqlFunctions\SqlFunctions.fsproj">
<Name>SqlFunctions</Name>
<Project>{14eefa95-3b68-4348-a7de-db29bfb3567f}</Project>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Thanks again.
Edit 2: As I comment below--the situation has progressed (I think) to: Invalid attempt to read when Reader is closed--error on the type declaration.
I'm trying to make a chat app and want to use SignalR. But when I try to install the Nuget-package I keep getting this error.
Microsoft.AspNet.SignalR.Core 2.2.1 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0) / win-x86.
I tried to find a solution but all the solutions I found claim to modify the dependencies in project.json. I'm using VS2017 and I don't have project.json but I can edit the dependencies in the project.csproj file, which looks like this.
<ItemGroup>
<PackageReference Include="Gma.QrCodeNet.Encoding" Version="1.0.1" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Session" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.0.0" PrivateAssets="All"/>
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
<PackageReference Include="System.Xml.XmlDocument" Version="4.3.0" />
Does anybody have any idea how to remove this error so I can use SignalR to make a chat application
Following is a simple nlog configuration containing simple logfile target. My problem is how to add a target for Nlog.Targets.Redis?
<targets>
<target name="logfile" xsi:type="File" fileName="file.txt" />
</targets>
Following is the right configuration for NLog.Targets.Redis. If you get the package with nuget, notice that nuget installs wrong NLog version, so you should put the dependentAssembly section like below.
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<runtime>
<dependentAssembly>
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="en-us" />
<bindingRedirect oldVersion="2.0.0.0" newVersion="2.0.1.2" />
</dependentAssembly>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true">
<extensions>
<add assembly="NLog.Targets.Redis" />
</extensions>
<targets>
<target name="redis" type="Redis" host="192.168.56.2" key="logstash" />
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="redis" />
</rules>
</nlog>
</configuration>