我们将一些web项目更改为SDK样式,但是如果我们在Visual中启动该项目,它将不会启动浏览器。IISExpress命令提示符确实运行并启动网站,因此当手动访问网站时,它可以工作。
在使用SDK样式的项目时,可以启动浏览器吗?(或者有没有解决办法/工具使之成为可能?)我知道,对于dotnet核心网站,这是可行的,并且启动了一个新的浏览器实例,也许我们应该保留.NET框架web项目的旧格式。
launchSettings.json
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:29750/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "Executable",
"executablePath": "C:\\Program Files\\IIS Express\\iisexpress.exe",
"commandLineArgs": "/path:\"$(SolutionDir)$(ProjectName)\" /port:29750",
"launchBrowser": true,
"launchUrl": "/"
}
}
}项目、删除脚本和很少视图()
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<AssemblyName>Web</AssemblyName>
<OutputType>Library</OutputType>
<OutputPath>bin\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Antlr" Version="3.5.0.2" />
<PackageReference Include="Castle.Windsor" Version="3.4.0" />
<PackageReference Include="Castle.Windsor.Mvc" Version="1.3.0" />
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.7" />
<PackageReference Include="Microsoft.AspNet.Web.Optimization" Version="1.1.3" />
<PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="2.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Owino" Version="1.0.2" />
<PackageReference Include="SignalR.Castle.Windsor" Version="1.0.1" />
<PackageReference Include="Westwind.Globalization" Version="3.0.5" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Web" />
</ItemGroup>
<ItemGroup>
<Compile Remove="obj\**" />
<EmbeddedResource Remove="obj\**" />
<EntityDeploy Remove="obj\**" />
<None Remove="node_modules\**" />
<None Remove="fonts\**" />
<None Remove="obj\**" />
<None Remove="Scripts\dist\**" />
<None Remove="package-lock.json" />
<None Include=".babelrc" />
<None Include=".eslintignore" />
<None Include="package.json" />
<None Include="Views\Protocol\Index.cshtml" />
<None Include="Views\Settings\Index.cshtml" />
<None Include="Views\Shared\_Root.cshtml" />
<None Include="Views\Shared\_Shared.cshtml" />
</ItemGroup>
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>信息
VisualStudio2019 (16.4.2)
发布于 2020-01-07 10:16:46
导入System.Diagnostics后,您可以在启动的底部插入以下示例。
Process.Start("chrome.exe", "https://google.com");发布于 2020-01-01 12:48:35
你能试着换一下json吗?
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
"applicationUrl": "http://localhost:29750/"
}https://stackoverflow.com/questions/59543356
复制相似问题