我使用Asp.Net MVC 3,C#和ApplicationServices Membership(标准方式起诉MS Sql 2008 db).
我的文件夹结构是
CONTROLLERS
-- PageAController.cs
-- ADMIN
-- PageBController.cs
Run Code Online (Sandbox Code Playgroud)
我有一些用户角色为"AdminRole",有些没有相关规则(匿名者).
我希望DENY访问特定的Controller并显示一个LOGIN页面,PageAController.cs以及为ADMIN没有"AdminRole"关联的用户显示文件夹内的所有控制器.
只要我在我的Web应用程序中加载JqueryMobile,就会收到此错误,遗憾的是我无法理解为什么会出现此问题.你能指出我正确的方向吗?谢谢!
Uncaught TypeError: Object function ( name, base, prototype ) {
var namespace = name.split( "." )[ 0 ],
fullName;
name = name.split( "." )[ 1 ];
fullName = namespace + "-" + name;
if ( !prototype ) {
prototype = base;
base = $.Widget;
}
// create selector for plugin
$.expr[ ":" ][ fullName ] = function( elem ) {
return !!$.data( elem, name );
};
$[ namespace ] = $[ namespace ] || {};
$[ namespace ][ name …Run Code Online (Sandbox Code Playgroud) 我使用EF 4.1 with Repository和DbContext .. POCO with T4 template.对于每个存储库,我使用单独的DbContext.
我收到此错误时,我需要更新具有相关属性的对象
An entity object cannot be referenced by multiple instances of IEntityChangeTracker.
Run Code Online (Sandbox Code Playgroud)
我想我的问题是beacuse eventObj并且candidate是从不同的存储库创建的.
所以我试图用这段代码解决问题,但没有成功.
我的问题?
是否有可能从其背景中删除候选人?
public void UpdateAddingCandidate(Event eventObj, Candidate candidate){
Event updatedEvent = new Event();
Candidate updatedCandidate = new Candidate();
updatedEvent = eventObj;
updatedCandidate = candidate;
updatedEvent.Candidate = updatedCandidate;
db.Entry(updatedEvent).State = EntityState.Modified;
}
Run Code Online (Sandbox Code Playgroud)编辑
public void UpdateAddingCandidate(Event eventObj, Candidate candidate)
{
/*
db.Events.AsNoTracking();
db.Candidates.AsNoTracking();
*/
db.Entry(eventObj).State = EntityState.Detached;
db.Entry(candidate).State = EntityState.Detached;
Event updatedEvent = …Run Code Online (Sandbox Code Playgroud) asp.net entity-framework repository-pattern entity-framework-4
在我的Razor视图中,我使用了DroDownList,我想让这个控件不可选.怎么做,(请发一个样品)?
<div class="editor-field">
@Html.DropDownListFor(x => x.CandidateId, Model.CandidatesList)
</div>
Run Code Online (Sandbox Code Playgroud) 我需要在页面的左上角(顶部和左侧= 0)放置div id ="wrapper",就像id ="test"div一样.你能指出我的代码有什么问题吗?
为了您的愿景:http: //jsfiddle.net/Q9fzX/
<div id="wrapper">
<div class="content">
<ul>
<li class="focus">0</li>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
<li>11</li>
<li>12</li>
<li>13</li>
<li>14</li>
<li>15</li>
<li>16</li>
<li>17</li>
<li>18</li>
<li>19</li>
<li>20</li>
<li>21</li>
<li>22</li>
<li>23</li>
<li>24</li>
<li>25</li>
<li>26</li>
<li>27</li>
<li>28</li>
<li>29</li>
<li>30</li>
<li>31</li>
<li>32</li>
<li>33</li>
<li>34</li>
<li>35</li>
<li>36</li>
<li>37</li>
<li>38</li>
<li>39</li>
</ul>
</div>
</div>
<div id="navigator">
<div id="up" class="btn">UP</div>
<div id="down" class="btn">DOWN</div>
<div id="left" class="btn">LEFT</div>
<div id="right" class="btn">RIGHT</div>
<div id="pageinfo" class="pageinfo">Page 1 of tot 4</div>
</div> …Run Code Online (Sandbox Code Playgroud) 我使用的是asp.net 4.5和最新的MVC版本.在html页面中发布表单时deviceId,我需要retrive 和bodyheader.在行public void Post([FromBody]string value)值处,它始终为null.
我在这做错了吗?
namespace WebApi.Controllers
{
public class NotificationController : ApiController
{
// GET api/notification
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/notification/5
public string Get(int id)
{
return "value";
}
// POST api/notification
public void Post([FromBody]string value)
{
// value it is always null
}
// PUT api/notification/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE api/notification/5
public void Delete(int …Run Code Online (Sandbox Code Playgroud) using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Configuration;
Run Code Online (Sandbox Code Playgroud)
我收到此错误
cannot declare instance members in a static class
Run Code Online (Sandbox Code Playgroud)
在编写静态类时。如果可能的话,知道如何解决它保持类静态吗?谢谢
namespace XXX.Helpers
{
public static class Utility
{
public static string GetConfiguration(string section, string key)
{
NameValueCollection mySection = (NameValueCollection)ConfigurationManager.GetSection(section);
return mySection[key];
}
}
}
Run Code Online (Sandbox Code Playgroud) 我需要从UriSrouce创建一个BitmaImage并打印它(在WPF应用程序中).使用以下代码我可以打印图像:
Image imgVoucher = new Image();
BitmapImage bImgVoucher = new BitmapImage();
bImgVoucher.BeginInit();
bImgVoucher.UriSource = new Uri(@"C:\logo-1.png", UriKind.Absolute); // Print ok
bImgVoucher.EndInit();
imgVoucher.Source = bImgVoucher;
Run Code Online (Sandbox Code Playgroud)
相同的代码和相同的图像,但UriSource指向Web服务器,图像不会打印,也不会引发错误.知道我做错了什么吗?
Image imgVoucher = new Image();
BitmapImage bImgVoucher = new BitmapImage();
bImgVoucher.BeginInit();
bImgVoucher.UriSource = new Uri("http://123123.com/logo.png", UriKind.Absolute); // Does not print
bImgVoucher.EndInit();
imgVoucher.Source = bImgVoucher;
Run Code Online (Sandbox Code Playgroud) 我在WPF应用程序中有一个特定的TextBlock.我需要为该特定的TextBlock创建大写文本.
尝试使用以下代码我收到此错误:
{"'TextUpperCase' is not a valid value for property 'Style'."}
Run Code Online (Sandbox Code Playgroud)
知道怎么解决吗?
<Style x:Key="TextUpperCase" TargetType="{x:Type TextBox}">
<Setter Property="CharacterCasing" Value="Upper"/>
</Style>
<TextBlock
x:Name="ShopNameTextBlock"
TextWrapping="Wrap"
Text="{Binding Description, FallbackValue=Shop name}"
Style="TextUpperCase"
VerticalAlignment="Center"
FontFamily="/GateeClientWPF;component/Fonts/#Letter Gothic L"
FontSize="45"
Grid.ColumnSpan="2"
Margin="0,60,0,0"
FontWeight="Medium"
TextAlignment="Center"
Foreground="Black"
/>
Run Code Online (Sandbox Code Playgroud) 我需要记录ApiController中的异常.
安装Elmah.MVC后,我可以在DB中记录404错误和其他错误,但ApiController中的异常不会显示在Elmah中.
知道怎么解决这个问题吗?
<modules>
<remove name="FormsAuthenticationModule" />
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
</modules>
<elmah>
<security allowRemoteAccess="yes" />
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="XXX"/>
</elmah>
public class StatusController : ApiController
{
private StatusBLL statusBLL = new StatusBLL();
// POST api/status
public void Post(StatusDTO status)
{
throw new ArgumentException("test elmah here");
if (!statusBLL.Register(status))
helpers.BusinessLayer.CreateResponseApiMessage(statusBLL.Errors);
}
}
Run Code Online (Sandbox Code Playgroud) asp.net-mvc ×4
c# ×4
.net ×3
asp.net ×2
html ×2
wpf ×2
css ×1
css-float ×1
elmah ×1
elmah.mvc ×1
javascript ×1
jquery ×1
razor ×1
wpf-controls ×1
xaml ×1