我在我的ASP.NET Core MVC
视图页面中使用了ajax调用
MyView.cshtml
$.ajax({
processData: false,
contentType: false,
data: new FormData(this),
type: $(this).attr('method'),
url: $(this).attr('action'),
cache: false,
success: function (data) {
$('#mydiv).html(data);
$('#bootstrapModal).modal('show');
Run Code Online (Sandbox Code Playgroud)
控制器发布方法"
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> MyLongRunningMethod(MyViewModel viewModel)
{
await MyProcess.Longprocess1();
await MyProcess.Longprocess2();
await MyProcess.Longprocess3();
await MyProcess.Longprocess4();
return PartialView("_MyPartialPage");
}
Run Code Online (Sandbox Code Playgroud)
这有效,但只对长时间运行的过程有问题.在调试模式下,当进程花费的时间超过大约2分钟时,我收到以下错误
我理解这与过期超时有关
在以前版本的ASP.NET MVC中,您显然可以增加asp.net控制器操作的超时.
HttpContext.Current.Server.ScriptTimeout = 90000;
Run Code Online (Sandbox Code Playgroud)
然而,这不存在于 ASP.NET Core
我想增加特定asp.net控制器的调试和部署超时.
对于生产,我可以web.config
通过将requestTimeout添加到现有的httpPlatform标记来全局设置它.例如10分钟
<httpPlatform requestTimeout="00:10:00" ....
Run Code Online (Sandbox Code Playgroud)
一个类似的问题被问到,但答案给出了使用CancellationToken
但阅读它,它似乎不能帮助我超时.
ASP.NET 4
?当我查看ASP.NET 3 Identity时,它使用a string
而不是a Guid
用于唯一主键.
在我的Entity Framework
code first
用户ApplicationUser
类中,我继承了Identity类
public class ApplicationUser : IdentityUser
{
}
Run Code Online (Sandbox Code Playgroud)
这导致在我创建实体框架迁移时aspnetusers
,使用密钥类型nvarchar(450)
而不是创建的表创建uniqueidentifier
当我将它与ASP.NET Identity 2
ENtity Framework
项目进行比较时,它创建了一个ID字段uniqueidentifier
而不是nvarchar(450)
我会想象对于数据库性能主键和外键uniqueidentifier
会更好nvarchar(450)
有没有办法用于唯一键Guid
而不是用string
而uniqueidentifier
不是nvarchar(450)
用ASP.NET Identity 3
?
先前有一个问题如何将String转换为Guid,但我希望数据库表Id是Guid.
当长度为nvarchar(128)时,我发现了以前的BETA的另一个问题.给出的理由是并非所有数据库都支持Guids,并且它的灵活性也发生了变化.
是否必须有一种简单的方法从字符串更改为Guid而不重写整体identity 3
?
nvarchar(450)
在创建SQL Server数据库约束时,实际上是过度杀伤并提供各种警告.数据库管理员肯定不会喜欢这些警告.
c# asp.net-identity entity-framework-core asp.net-identity-3 asp.net-core
我创建了一个新的ASP.NET5 Beta 8 Web应用程序.
我将它发布到我的本地文件系统并将这些文件复制到我的服务器,即Windows Server 2012 R2
在服务器上的IIS 8.5中,我创建了一个应用程序,该应用程序使用使用Process Model - > Identity as LocalSystem的应用程序池.
我指向复制的已发布应用程序的wwwroot子文件夹的路径
我的web.config
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="..\approot\web.cmd" arguments="" stdoutLogEnabled="false" stdoutLogFile="..\logs\stdout.log" startupTimeLimit="3600"></httpPlatform>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
直接在服务器上运行URL或单击IIS中的"浏览"
http://localhost/WebApplication1
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
HTTP错误500.19 - 内部服务器错误
无法访问请求的页面,因为页面的相关配置数据无效.
我正在使用Visual Studio 2015 ASP.NET 5 Beta8 Web应用程序模板中的默认web.config,所以我只能认为它可能是.net版本.
我使用MSDN方法确定安装了哪个版本的.NET 4,它对应于.NET Framework 4.5.1
在我的project.json我有
"frameworks": {
"dnx451": { }
},
Run Code Online (Sandbox Code Playgroud)
我在发布时将其编译为Win CLR
当我转到部署目录中的approot文件夹时,我可以运行web.cmd Web服务器,然后通过创建的端口访问我的网站.
http://localhost:5000/
Run Code Online (Sandbox Code Playgroud)
这个网站工作正常.
如果我查看我的IIS服务器角色安装组件
ASP.NET 4.5已安装.
应用程序池是正确的.
ASP.NET 4网站使用相同的应用程序池在IIS中正确运行
我的问题1.为什么IIS说web.config无效?2.如何让IIS 5 Beta 8站点在IIS中运行?
我想获取ASP.NET Core
控制器的当前方法名称
我试过通过反射获取方法名称:
[HttpGet]
public async Task<IActionResult> CreateProcess(int catId)
{
string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
Run Code Online (Sandbox Code Playgroud)
但这给了我一个价值MoveNext
而不是CreateProcess
请注意我不想使用ViewContext
string methodName = ActionContext.RouteData.Values["action"].ToString();
Run Code Online (Sandbox Code Playgroud)
因为我通过启动设置小写我的网址.以上将createprocess
取代我CreateProcess
我最好想要一个简单的单行而不是多行扩展方法.
我想在ASP.NET Core MVC
项目中使用Reporting Services ReportViewer控件.
该解决方案在其他建议答案到一个Web窗体添加到项目中.
但是,由于ASP.NET Core
不支持webforms,我无法将控件添加到webform.
是否有任何其他解决方法可能有助于我在ASP.NET Core Web应用程序中使用ReportViewer控件?
reportviewer asp.net-core-mvc asp.net-core reportviewerformvc
我正在使用 .net framework 4.5
我收到以下错误
错误CS0453类型'MyObject'必须是非可空值类型才能在泛型类型或方法'Nullable'中将其用作参数'T'
public async Task<Nullable<MyObject>> MyMethod(string myParamter)
{}
Run Code Online (Sandbox Code Playgroud)
我也试过了
public async Task<MyObject?> MyMethod(string myParamter)
{}
Run Code Online (Sandbox Code Playgroud)
如果我将该东西设置为可空,那么为什么我会在方法名称下方的红线上显示此错误消息
stackoverflow 答案很简单,使返回类型可以为空,但对我来说Visual Studio不允许它.
我目前有Visual Studio 2015 Enterprise.我以前使用与尝试安装Beta 8相同的方法成功安装了ASP.NET Beta 7.
我使用了此BETA 8安装说明中描述的方法.
1.关闭Visual Studio的所有实例.
2.使用DotNetVersionManager-x64.msi安装.NET版本管理器(Beta8).对于32位机器,请使用DotNetVersionManager-x86.msi.
3.通过安装WebToolsExtensionsVS14.msi,使用ASP.NET和Web Tools 2015(Beta8)更新Visual Studio 2015.如果您使用的是Visual Studio 2015 Express for Web,请改为安装WebToolsExtensionsVWD14.msi.
在运行安装程序WebToolsExtensionsVS14.msi的第3步,我收到以下错误消息
此产品需要visual studio 14".请安装Visual Studio 14然后再次尝试安装此产品"
当我打开Visual Studio时,它显示我安装了版本14
然后,我通过运行卸载程序卸载了Beta 7并尝试安装Beta 8,但仍然出现错误.
我的问题:如何安装ASP.NET Beta 8?
在ASP.NET 5 MVC 6 Beta 8中,我需要在my中读取会话变量,_Layout.cshtml
或者获取对当前HttpContext的引用.
请注意:在ASP.NET 5中,引用Session对象已经从ASP.net 4发生了显着变化,详见本问题
该Context
对象也已重命名为HttpContext
Beta7和Beta8.
在我当前的控制器中,我目前保存会话变量
public IActionResult Index()
{
HttpContext.Session.SetInt32("Template", (id));
}
Run Code Online (Sandbox Code Playgroud)
在我的_Layout.cshtml中,我需要阅读上面的会话变量.我需要以某种方式引用当前的HttpContext,例如
HttpContext.Current.Session.GetInt32("Template");
Run Code Online (Sandbox Code Playgroud)
但我不知道如何在cshtml文件中获取当前的HttpContext.
ASP.NET 5 与System.Web.Mvc.Html.InputExtensions
ASP.NET 4 中使用的等效项是什么?
请参阅下面的示例:
public static class CustomHelpers
{
// Submit Button Helper
public static MvcHtmlString SubmitButton(this HtmlHelper helper, string buttonText)
{
string str = "<input type=\"submit\" value=\"" + buttonText + "\" />";
return new MvcHtmlString(str);
}
// Readonly Strongly-Typed TextBox Helper
public static MvcHtmlString TextBoxFor<TModel, TValue>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TValue>> expression, bool isReadonly)
{
MvcHtmlString html = default(MvcHtmlString);
if (isReadonly)
{
html = System.Web.Mvc.Html.InputExtensions.TextBoxFor(htmlHelper,
expression, new { @class = "readOnly",
@readonly = "read-only" });
} …
Run Code Online (Sandbox Code Playgroud) .NET Core上的ASP.NET Core是跨平台的ASP.NET.您可以在Windows,Linux和Mac上运行为.NET Core编写的应用程序.服务器不需要安装.NET框架.
但是.NET Framework上的ASP.NET Core(CLR)确实需要在Web服务器上安装.net框架.
如果我在.NET Framework(CLR)模板上创建新的ASP.NET Core,则使用的默认框架是.NET 4.52
在里面 project.json
"frameworks": {
"net452": { }
},
Run Code Online (Sandbox Code Playgroud)
如果我将此值更改为更晚或更早,例如
"frameworks": {
"net451": { }
},
Run Code Online (Sandbox Code Playgroud)
该项目将支持该版本.
ASP.NET Core on .NET Framework(CLR)项目支持哪些版本的版本?
asp.net-core ×9
c# ×5
deployment ×1
generics ×1
html-helper ×1
iis ×1
iis-8 ×1
reflection ×1
reportviewer ×1
timeout ×1