小编Ale*_*x B的帖子

何时在ASP.NET MVC中调用Session_End()?

Web.Config在ASP.NET MVC 2项目中配置了我的文件:

<sessionState mode="InProc" timeout="1"/>
Run Code Online (Sandbox Code Playgroud)

并添加以下内容Global.asax.cs:

protected void Session_End(object sender, EventArgs e)
{
    System.Diagnostics.Debug.WriteLine("Session_End");
}

protected void Session_Start(object sender, EventArgs e)
{
    System.Diagnostics.Debug.WriteLine("Session_Start");
}
Run Code Online (Sandbox Code Playgroud)

Session_Start()在新用户访问网站时调用.我希望Session_End()在1分钟的空闲时间之后被召唤,但事实并非如此.我错过了什么吗?

asp.net-mvc web-config session-state session-timeout

18
推荐指数
2
解决办法
3万
查看次数

ASP.NET MVC:默认页面上的AuthorizeAttribute

我的ASP.NET MVC项目中的默认控制器使用[Authorize]属性进行修饰.当我在我的开发机器上部署网站并访问网站时,我被重定向到登录页面(在Web.Config的窗体loginUrl部分中定义).结果:一切都按预期工作.

当我在我们的生产服务器(Windows Server 2008,IIS 7,DefaultAppPool)上发布网站并访问网站时,预期地址显示在地址栏(/Account/LogOn?ReturnUrl=*my_expected_return_url*)中,但页面显示"您无权查看此目录或页." 而不是登录页面.如果我删除默认控制器/操作上的[Authorize]属性,页面将正确显示.

我的Web.Config文件:

sessionState mode="InProc" timeout="30"  
     authentication mode="Forms"  
        forms loginUrl="~/Account/LogOn" timeout="2880"
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc forms-authentication

5
推荐指数
1
解决办法
1851
查看次数

使用带有在不同字典中定义的样式的BasedOn属性

我正在处理的应用程序有2个ResourceDictionary,DefaultStyles.xaml和CustomStyles.xaml.

CustomStyles字典中的样式是否可能使用其他字典中定义的基本样式?

DefaultStyles.xaml:

<Style x:Key="TextBlockDefaultStyle" TargetType="TextBlock">  
    <Setter Property="Margin" Value="4" />  
</Style>  
Run Code Online (Sandbox Code Playgroud)

CustomStyles.xaml:

<Style x:Key="SectionTitleStyle" TargetType="TextBlock" BasedOn="{StaticResource TextBlockDefaultStyle}">
    <Setter Property="FontSize" Value="16" />
</Style>
Run Code Online (Sandbox Code Playgroud)

App.xaml中:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Assets/Styles/DefaultStyles.xaml"/>
            <ResourceDictionary Source="Assets/Styles/CustomStyles.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)

代码运行时,抛出以下异常:

找不到具有Name/Key TextBlockDefaultStyle的资源.

如果两个样式都在同一个文件中,它的效果很好.

c# silverlight resourcedictionary mergeddictionaries

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

在Silverlight中的TextBlock后显示一行

我正在使用Silverlight 4中的数据表,并且希望按部分对元素进行分组,每个元素都有一个标题.标题由TextBlock后跟水平线组成.该行一直运行到表单的边缘.

我尝试过以下内容(来自此主题:http://forums.silverlight.net/forums/p/77813/183885.aspx),但没有成功:

<StackPanel Orientation="Horizontal"/>
    <TextBlock Text="Section title" />
    <Line X1="0" Y1="0" X2="1" Y2="0" Stretch="Fill" Stroke="Black" />
</StackPanel>
Run Code Online (Sandbox Code Playgroud)

知道为什么这不起作用吗?

谢谢!

silverlight xaml

2
推荐指数
1
解决办法
6832
查看次数

在数据网格标题中绑定复选框

我有一个数据网格,其中第一列包含一个复选框,让用户选择特定行。我在数据网格列标题中添加了一个复选框来选中或取消选中所有行。

是否可以仅通过 XAML 中的绑定来添加此功能(无检查事件)。

<sdk:DataGrid AutoGenerateColumns="False" Grid.Row="1"  Name="grid" ItemsSource="{Binding myCollection, Mode=TwoWay}" >
        <sdk:DataGrid.Columns>
            <sdk:DataGridCheckBoxColumn Binding="{Binding myCollection.UserSelected, Mode=TwoWay}" >
                <sdk:DataGridCheckBoxColumn.HeaderStyle>
                    <Style TargetType="sdk:DataGridColumnHeader">
                        <Setter Property="ContentTemplate">
                            <Setter.Value>
                                <DataTemplate>
                                    <CheckBox x:Name="checkAll" IsThreeState="True"  
                                              IsChecked="{Binding myCollection.UserSelected, Mode=TwoWay, Converter={StaticResource threeStateConverter}}"/>
                                </DataTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </sdk:DataGridCheckBoxColumn.HeaderStyle>
            </sdk:DataGridCheckBoxColumn>
            <sdk:DataGridTextColumn Binding="{Binding Description}" Header="Chemin" />
        </sdk:DataGrid.Columns>
    </sdk:DataGrid>
Run Code Online (Sandbox Code Playgroud)

我认为“myCollection.UserSelected”部分有问题。ThreeStateConverter是一个值转换器,当选择某些项目时返回 null,当全部选择项目时返回 true,等等,但该Convert方法永远不会被调用(即使在更改PropertyChanged时引发事件)。UserSelected

关于我该怎么做有什么想法吗?谢谢。

silverlight xaml

2
推荐指数
1
解决办法
7075
查看次数

如何在Silverlight中获取应用程序的ProductName

是否可以以编程方式获取Silverlight应用程序的ProductName?我正在寻找Silverlight等效的WinForms/WPF指令:

string productName = System.Windows.Forms.Application.ProductName;
Run Code Online (Sandbox Code Playgroud)

谢谢

silverlight

2
推荐指数
1
解决办法
1397
查看次数