我有以下控制器操作:
[ChildActionOnly]
public virtual PartialViewResult ListActions(int id)
{
var actions = meetingActionRepository.GetAllMeetingActions(id);
return PartialView(actions);
}
Run Code Online (Sandbox Code Playgroud)
以及以下操作链接(使用t4MVC和razor语法)
<p>
@Html.RenderAction(MVC.MeetingActions.ListActions(Model.MeetingId))
</p>
Run Code Online (Sandbox Code Playgroud)
但是这给了我错误:
不能隐式地将类型void转换为对象
至于我可以告诉控制器动作是好的,那么什么可以给我这个错误?
我有一个Enum称为ActionStatus,它有两个可能的值open = 0和closed = 1
public enum ActionStatus
{
Open,
Closed
}
Run Code Online (Sandbox Code Playgroud)
我想在我的编辑中构建单选按钮组,并创建使用枚举来填充单选按钮的视图,其中a)创建视图中的默认值和b)编辑视图中当前选定的选项.
我需要一个扩展方法,并且有人已经创建了一个吗?
编辑:在Darins的答案之后,这是我的Model课程
namespace Actioner.Models
{
[MetadataType(typeof(MeetingActionValidation))]
public class MeetingAction
{
[Key]
public int MeetingActionId { get; set; }
[Required]
[Display(Name = "Description")]
public string Description { get; set; }
[Required]
[Display(Name = "Review Date")]
public DateTime ReviewDate { get ;set; }
public int Status{ get; set; }
[ScaffoldColumn(false)]
public int MeetingId { get; set; }
//public virtual Meeting Meeting { get; set; }
//public virtual ICollection<User> Users …Run Code Online (Sandbox Code Playgroud) 我正在尝试将参数传递给XSLT样式表,但是当使用XSlCompiledTransform转换文档时,我得到的是一个空的xml文档.
这是用于添加参数的C#方法(在添加人们的建议之后)
private static void CreateHierarchy(string manID)
{
string man_ID = manID;
XsltArgumentList argsList = new XsltArgumentList();
argsList.AddParam("Boss_ID","",man_ID);
XslCompiledTransform transform = new XslCompiledTransform();
transform.Load("htransform.xslt");
using (StreamWriter sw = new StreamWriter("output.xml"))
{
transform.Transform("LU AIB.xml", argsList, sw);
}
}
Run Code Online (Sandbox Code Playgroud)
这是样式表.我传入的参数是'Boss_ID'
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="OrgDoc">
<xsl:param name="Boss_ID"></xsl:param>
<xsl:processing-instruction name="xml-stylesheet">
<xsl:text>type="text/xsl" href="..\styles\orgcharts.xsl" </xsl:text>
</xsl:processing-instruction>
<OrgDoc>
<xsl:for-each select="PosDets[@OC_Man = $Boss_ID]">
<PosDets OC_Pos="{@OC_Pos}" OC_Sub="{@OC_Sub}" OC_Man="{@OC_Man}" OC_Ttl="{@OC_Ttl}" OC_Rnk="{@OC_Rnk}" OC_Bdg="{@OC_Bdg}" OC_Fnd="{@OC_Fnd}" OC_OL3="{@OC_OL3}" OC_Tmp="{@OC_Tmp}">
<xsl:apply-templates select="../PosDets">
<xsl:with-param name="mgrid" select="@OC_Pos"/>
</xsl:apply-templates>
</PosDets> …Run Code Online (Sandbox Code Playgroud) 我对这个感到困惑,你的帮助最有用.
我收到错误:
从类型'System.String'到类型'DataPortal.Models.EntityClasses.FeedbackComment'的参数转换失败,因为没有类型转换器可以在这些类型之间进行转换
这ModelState.IsValid是失败的FeedbackComment.Comment财产
有任何想法吗?
public class FeedbackComment : IFeedbackComment
{
[Key]
public int Id { get; set;}
public int FeedbackId { get; set; }
[Required(ErrorMessage = "Please enter a Comment")]
public string Comment { get; set; }
public DateTime CommentDate { get; set; }
public string CommentBy { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
控制器方法
//
// GET: /FeedbackComment/Create
public virtual ActionResult Create(int feedbackId)
{
var comment = new FeedbackComment {FeedbackId = feedbackId, CommentBy = User.Identity.Name, CommentDate …Run Code Online (Sandbox Code Playgroud) 我有以下模型
public class FilanthropyEvent : EntityBase, IDeleteable
{
public int Id { get; set; }
public string Name { get; set; }
public DateTime EventDate { get; set; }
public string Description { get; set; }
public decimal Target { get; set; }
public decimal EntryFee { get; set; }
public bool Deleted { get; set; }
public ICollection<EventAttendee> EventAttendees { get; set; }
}
public class Attendee : EntityBase, IDeleteable
{
public int Id { get; set; }
public …Run Code Online (Sandbox Code Playgroud) 一家外部公司已经对我正在开发的ASP.NET MVC 5应用程序进行了一些渗透测试.
他们提出的问题描述如下
与会话管理链接的cookie称为AspNet.ApplicationCookie.手动输入时,应用程序会对用户进行身份验证.即使用户从应用程序注销,cookie仍然有效.这意味着,旧会话cookie可以在无限时间范围内用于有效身份验证.在插入旧值的那一刻,应用程序接受它并用新生成的cookie替换它.因此,如果攻击者获得对现有cookie之一的访问权限,则将创建有效会话,其访问权限与过去相同.
我们正在使用ASP.NEt Identity 2.2
这是我们在帐户控制器上的注销操作
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
AuthenticationManager.SignOut();
return RedirectToAction("Login", "Account");
}
Run Code Online (Sandbox Code Playgroud)
在startup.auth.cs中
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
ExpireTimeSpan = TimeSpan.FromHours(24.0),
Provider = new CookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator
.OnValidateIdentity<ApplicationUserManager, ApplicationUser, …Run Code Online (Sandbox Code Playgroud) 我有一个Web Api 2应用程序,有两个类都依赖于另一个类,我正在使用ninject来解决依赖性.
public class AuthorizationServerProvider : OAuthAuthorizationServerProvider
{
private IUserService _userService;
public AuthorizationServerProvider(IUserService userService)
{
_userService = userService;
}
}
public class RefreshTokenProvider : IAuthenticationTokenProvider
{
private IUserService _userService;
public RefreshTokenProvider(IUserService userService)
{
_userService = userService;
}
Run Code Online (Sandbox Code Playgroud)
在startup.cs类中,我需要使用上面的两个类,但当然我不能在启动类中使用构造函数注入,因为它是在Ninject之前初始化的.
有什么方法可以在ConfigureAuth方法中引用_tokenProvider和_authServerProvider?
public class Startup
{
private AuthorizationServerProvider _authServerProvider;
private RefreshTokenProvider _tokenProvider;
public static OAuthBearerAuthenticationOptions OAuthBearerOptions { get; private set; }
public void Configuration(IAppBuilder app)
{
var config = new HttpConfiguration();
app.UseNinjectMiddleware(CreateKernel);
app.UseNinjectWebApi(config);
ConfigureOAuth(app);
WebApiConfig.Register(config);
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
app.UseWebApi(config);
}
public void ConfigureOAuth(IAppBuilder app) …Run Code Online (Sandbox Code Playgroud) 尝试从我们新创建的私有Nuget Feed安装包时,出现以下错误.
无法安装包'GC.Timecode 1.0.0.3'.您正在尝试将此软件包安装到以".NETFramework,Version = v4.5.1"为目标的项目中,但该软件包不包含任何与该框架兼容的程序集引用或内容文件.
Nuget包也针对4.5.1.(截图来自Nuget Package Explorer)
Nuget Package由Octopack通过On premises TFS创建,然后发布到私有Proget Server
Nuspec文件看起来像这样
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>GC.Timecode</id>
<version>1.0.0.3</version>
<authors>user</authors>
<owners>user</owners>
<licenseUrl>http://example.com</licenseUrl>
<projectUrl>http://example.com</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>The GC.Timecode deployment package, built on 25/01/2016</description>
<releaseNotes />
</metadata>
</package>
Run Code Online (Sandbox Code Playgroud)
包的内容
这里发生了什么?
我将在明天为我正在工作的会议应用程序编写一个自定义日期验证课程,该会议应用程序将验证给定的开始或结束日期是否小于当前日期,或者B)开始日期更长比会议结束日期(反之亦然).
我认为这可能是一个相当普遍的要求.任何人都可以指向我的博客文章的方向,可能会帮助我解决这个问题?
我正在使用.net 3.5所以我不能使用.NET 4中内置的新模型验证器api.我正在研究的项目是MVC 2.
更新:我正在编写的类需要扩展System.ComponentModel.DataAnnotations命名空间.在.NET 4中有一个你可以实现的IValidateObject接口,这使得这种事情变得绝对轻而易举,但遗憾的是我不能使用.Net 4.我如何在.Net 3.5中做同样的事情?
是否有任何.NET库将字符串解析为公式?
即; "如果用户输入"(2 + 5)*2",图书馆将能够计算出来吗?
编辑:最好能适用于Windows Phone 7而不需要太多摆弄的东西会很棒!