小编Cha*_*ell的帖子

ASP.NET MVC显示格式不将DateTime格式化为日期字符串

我的显示格式设置如此

<DisplayName("birthdate")> _
<DisplayFormat(ApplyFormatInEditMode:=True, DataFormatString:="{0:MM/dd/yyyy}")> _
Public Property BirthDate As DateTime
Run Code Online (Sandbox Code Playgroud)

然后在视图中我有以下内容

<%: Html.TextBoxFor(Function(model) model.BirthDate, Model.BirthDate)%>
<%: Html.ValidationMessageFor(Function(model) model.BirthDate) %>
Run Code Online (Sandbox Code Playgroud)

意味着输出"应该"

1982年6月24日

但不幸的是,输出是

6/24/1982 12:00:00 AM

有谁知道我在这里可能会缺少什么?

asp.net-mvc metadata string-formatting

4
推荐指数
1
解决办法
4293
查看次数

在Visual Studio中运行宏时获取光标位置

我有一个我运行的宏,它为我的文档写了一个版权标题.当前写入标题时,光标留在标题的末尾.

我希望能够捕获当前位置,写入标题,然后将光标返回到原始位置.

有谁知道如何实现这一目标?

macros visual-studio

4
推荐指数
1
解决办法
1412
查看次数

如何在ASP.NET Membership Cookie中存储自定义数据

关于如何在ASP.NET会员cookie中存储自定义数据,任何人都可以给我一个例子(或指出我正确的方向)吗?

我需要向cookie添加一些自定义属性,如UserID和URLSlug,并能够以检索用户名的相同方式检索信息.

编辑:

我使用了Code Poet的例子并提出了以下内容.

当我设置一个断点时Dim SerializedUser As String = SerializeUser(userData),值userData是对的.它具有我期望它拥有的所有属性.

我现在遇到的问题是,当我到达Dim userdata As String = authTicket.UserData(断点)时,值是"".我想知道我做错了什么.

这是代码.

Imports System
Imports System.Web
Imports System.Web.Security

Namespace Utilities.Authentication
    Public NotInheritable Class CustomAuthentication
        Private Sub New()
        End Sub

        Public Shared Function CreateAuthCookie(ByVal userName As String, ByVal userData As Domain.Models.UserSessionModel, ByVal persistent As Boolean) As HttpCookie

            Dim issued As DateTime = DateTime.Now
            ''# formsAuth does not expose timeout!? have to hack around the
            ''# spoiled parts …
Run Code Online (Sandbox Code Playgroud)

vb.net asp.net asp.net-membership

4
推荐指数
2
解决办法
7676
查看次数

jQuery TimeAgo插件 - 设置设置

我正在尝试"调整"TimeAgo插件,以便我可以根据具体情况删除后缀"之前".

这是我尝试过的

$("time.timeago-nosuffix").timeago({suffixAgo: ""});
Run Code Online (Sandbox Code Playgroud)

$("time.timeago-nosuffix").timeago({ settings: { strings: { suffixAgo: null}} });
Run Code Online (Sandbox Code Playgroud)

以及

$(document).ready(function () {
    $("time.timeago").timeago();
    $("time.timeago-nosuffix").timeago(function () {
        suffixAgo: "" 
    });
});
Run Code Online (Sandbox Code Playgroud)

没有运气.

jquery plugins timeago

4
推荐指数
1
解决办法
2542
查看次数

ASP.NET MVC3 - ActionResult将DotNetOpenAuth WebResponse呈现为String

我刚刚更新了我的MVC2项目来运行MVC3(RC).除了一个问题,一切都按预期工作.

我正在运行DotNetOpenAuth,但是当我进行身份验证时,我的页面会呈现字符串

DotNetOpenAuth.Messaging.OutgoingWebResponseActionResult

而不是验证(在MVC2应用程序中工作)

我在其他地方发现了这个问题,我做了所建议的,但无济于事.

这是我的Web.Config的剪辑

</configSections>
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc"
                publicKeyToken="31bf3856ad364e35"/>
            <bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>
<system.web.webPages.razor>
Run Code Online (Sandbox Code Playgroud)

还有什么可能导致这个问题?

如果它有帮助,这是在MVC3之前工作的Controller代码

    ''# <ValidateInput(False)> _  ''# this code is commented out so that it displays properly on StackOverflow - It's not really commented out in the project.
    Public Function Authenticate(ByVal go As String) As ActionResult
        Dim response As IAuthenticationResponse = openid.GetResponse()
        If response Is Nothing Then
            ''# Stage 2: user submitting Identifier
            Dim id As Identifier

            If …
Run Code Online (Sandbox Code Playgroud)

asp.net dotnetopenauth asp.net-mvc-3

4
推荐指数
1
解决办法
1398
查看次数

子域上的单个OpenID

我在OpenOverflow上使用的OpenID与此处的OpenID非常相似,可以对我的用户进行身份验证.我真正需要做的是让OpenID在我网站的所有子域中工作.

该网站的行为与Kijiji大致相同,因为每个区域都有自己的子域

  • calgary.example.com
  • toronto.example.com
  • vancouver.example.com
  • 等等

当用户登录"calgary"并稍后登录"toronto"时,他们将被迫在提供者处"给予许可",从而产生新的OpenID并导致新的登录.

我的应用程序"可以"在一个帐户下有多个OpenID,但管理起来会很麻烦.

有没有办法让提供商链接到顶级域,然后跨所有子域工作?

我正在使用DotNetOpenAuth.

我认为我总是强迫用户登录http://example.com,然后使用表单身份验证domain = ".example.com"来导航到所有子域.

openid dotnetopenauth openid-provider

4
推荐指数
1
解决办法
903
查看次数

如何将JSON设置为本地URL的变量

显然jQuery让我愚蠢.

我有一个提供原始JSON的本地URL,我无法弄清楚如何在不使用jQuery的情况下从我的方法中使用json.

这是我用jQuery做的知道

var myJson;
$.getJSON('/local/path/to/json', function (data) { 
    myJson = data; 
});

// Now I can use myJson in a method.
Run Code Online (Sandbox Code Playgroud)

javascript json

4
推荐指数
1
解决办法
9894
查看次数

什么是网络服务?

有人可以用简单的方式向我解释一下,什么是网络服务?

如果我错了,请纠正我.我在网络的某个地方托管了一个数据库,我想从桌面应用程序和移动应用程序执行数据库事务.这可以通过Web服务完成吗?有人提到我,我想确保这可能发生.

database mobile desktop web-services transactions

4
推荐指数
1
解决办法
346
查看次数

ServiceStack AppHostHttpListenerBase无法连接到远程服务器

我正在我的应用程序上进行一些功能测试,我想我已经非常接近了.我的问题是,当我运行第一次测试时,我得到了错误.

无法连接到远程服务器.

预期:好的
但是:0

我可以确认,如果我在断言上设置断点,然后尝试BaseUrl在我的浏览器中点击,则找不到它.

这是我的考试.

[Test]
public void MyTestTest ()
{
    var client = new RestClient( ServiceTestAppHostBase.BaseUrl );
    // client.Authenticator = new HttpBasicAuthenticator( NUnitTestLoginName, NUnitTestLoginPassword );
    var request = new RestRequest( "/users/", Method.GET );
    request.RequestFormat = DataFormat.Json;
    var response = client.Execute( request );

    // do assertions on the response object now
    Assert.That( response.StatusCode, Is.EqualTo( HttpStatusCode.OK ) );
}
Run Code Online (Sandbox Code Playgroud)

AppServerTestSetup这个样子的

[SetUpFixture]
public class AppServerTestSetup
{
    ServiceTestAppHostBase _appHost;

    [SetUp]
    public void SetUp()
    {
        _appHost = new ServiceTestAppHostBase(); …
Run Code Online (Sandbox Code Playgroud)

c# functional-testing servicestack

4
推荐指数
1
解决办法
730
查看次数

如何使用ValidateSet并在Array参数上仍然允许$ null?

我有一个方法需要接受一个字符串数组作为参数,但该数组只能包含有效的字符串.我的问题是,如果我确保[AllowNull()],并且[AllowEmptyCollection()]该方法仍然失败

function SomethingSomethingAuthType {
    param(
        [parameter(Mandatory=$true,position=0)] 
        [ValidateSet('anonymousAuthentication','basicAuthentication','clientCertificateMappingAuthentication','digestAuthentication','iisClientCertificateMappingAuthentication','windowsAuthentication')] 
        [AllowNull()] 
        [AllowEmptyCollection()] 
        [array] $authTypes
    )

    $authTypes | % {
        Write-Host $_ -f Green
    }

}

SomethingSomethingAuthType $null
Run Code Online (Sandbox Code Playgroud)

SomethingSomethingAuthType:无法验证参数'authTypes'的参数.参数为null,为空,或者参数集合的元素包含空值.提供不包含任何空值的集合,然后再次尝试该命令.在行:16 char:32 + SomethingSomethingAuthType $ null + ~~~~~ + CategoryInfo:InvalidData:(:) [SomethingSomethingAuthType],ParameterBindingValidationException + FullyQualifiedErrorId:ParameterArgumentValidationError,SomethingSomethingAuthType

我需要做什么$null才能传入,还要验证集合以确保适当的类型?

validation powershell

4
推荐指数
1
解决办法
1867
查看次数