我使用Asp.Net 4和C#.
我想知道如何更改Asp.Net的默认beahviour customErrors.
在我的Web.Config文件中,我使用此设置.
<customErrors mode="On" defaultRedirect="/ErrorPages/Oops.aspx">
<error statusCode="404" redirect="/ErrorPages/404.aspx" />
</customErrors>
Run Code Online (Sandbox Code Playgroud)
正如您所期望的那样,如果找不到页面,则会在Web.Config中指定的自定义页面中进行重定向.
请求页面:
http://localhost:1372/nopagehere
Run Code Online (Sandbox Code Playgroud)
结果页面:
http://localhost:1372/ErrorPages/404.aspx?aspxerrorpath=/nopagehere
Run Code Online (Sandbox Code Playgroud)
当我分析结果页面的Http Header时,我可以看到:
我想以这种方式改变这种行为:
知道怎么做吗?谢谢你的时间.
我有一个带有body标签的布局.身体标签为css宽度为960px;
我想在body标签内部有一个DIV,我需要这个div是浏览器窗口的100%宽度.
不幸的是,目前我无法得到结果,因为内部div从身体继承.
我的问题; 即使在body标签内,如何强制div在当前浏览器窗口的100%宽度上缩放?
PS.我尝试!重要的宽度属性,但不起作用
谢谢
我使用asp.net 4,我的web.config有一些奇怪的问题,我收到此错误.似乎在该<compilation>部分内部有一些格式不正确的代码.
知道可能是什么?我尝试了不同的方式,但仍然无法正常工作.请提供一些代码示例.谢谢
无法访问请求的页面,因为页面的相关配置数据无效.无法读取配置节'程序集',因为它缺少节声明
<compilation debug="true" targetFramework="4.0" />
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="WebProject.Core"/>
<add assembly="WebProject.DataAccess"/>
<add assembly="WebProject.Cms"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Linq, Version=4.0.0.0, …Run Code Online (Sandbox Code Playgroud) 我使用asp.net 4 c#和EF 4.
我正在分析我的申请.我有这个代码,结果很昂贵.
我想知道你是否知道更好的写作方式.我需要加快速度.
string htmlhead = context.CmsOptions.SingleOrDefault(op => op.OptionId == 7).Value;
if (htmlhead != null)
uxHtmlHead.Text = htmlhead;
else
uxHtmlHead.Text = "No Html Head.";
Run Code Online (Sandbox Code Playgroud)
谢谢
我使用MS SQL 2008 R2,我需要在特定列上创建一个带有CHECK的表但是我收到此错误.你能指出我正确的方向吗?谢谢
HeatingSystem tinyint NOT NULL
CONSTRAINT CK_ReProperties_HeatingSystem CHECK(Size between 0 and 3),
Run Code Online (Sandbox Code Playgroud)
错误
消息8141,级别16,状态0,行1列"加热系统"列的CHECK约束引用另一列,表'ReProperties'.消息1750,级别16,状态0,行1无法创建约束.查看以前的错误.
我使用MVC 3,我有一个带有以下代码的控制器,我无法获取ViewModel [HttpPost] ActionResult删除AdvSlotDeleteViewModel结果为NULL,我有一个类似的Action方法,它正在运行,你能帮我解决这个问题吗? ?
// GET: /ManageAdvSlots/Delete/5
public ActionResult Delete(int id)
{
AdvSlot advSlot = advSlotRepository.FindById(id);
AdvSlotDeleteViewModel deleteViewModel = Mapper.Map<AdvSlot, AdvSlotDeleteViewModel>(advSlot);
return View(deleteViewModel);
}
//
// POST: /ManageAdvSlots/Delete/5
[HttpPost]
public ActionResult Delete(AdvSlotDeleteViewModel deleteViewModel)
{
if (ModelState.IsValid)
{
AdvSlot advSlot = Mapper.Map<AdvSlotDeleteViewModel, AdvSlot>(deleteViewModel);
advSlotRepository.Delete(advSlot.AdvSlotId);
advSlotRepository.Save();
}
return RedirectToAction("Index");
}
}
Run Code Online (Sandbox Code Playgroud)
视图
@model MyProject.ViewModels.AdvSlotDeleteViewModel
@{
ViewBag.Title = "Delete";
}
<h2>Delete</h2>
<h3>Are you sure you want to delete this?</h3>
<fieldset>
<legend>AdvSlotDeleteViewModel</legend>
<div class="display-label">AdvSlotId</div>
<div class="display-field">
@Html.DisplayFor(model => model.AdvSlotId)
</div>
<div class="display-label">Name</div>
<div …Run Code Online (Sandbox Code Playgroud) 我有一个方法,它使用了一些嵌套的if语句,所以我想知道是否有更好的方法来编写相同的逻辑.
例如,我想删除避免两次
_typologyRepository.Update(typology);
_typologyRepository.Save();
Run Code Online (Sandbox Code Playgroud)
你能指出我正确的方向吗?谢谢
public void Update(Typology typology, string nameOriginalValue)
{
if (typology.Name == nameOriginalValue)
{
_typologyRepository.Update(typology);
_typologyRepository.Save();
}
else
{
if (IsUniqueName(typology.Name))
{
_typologyRepository.Update(typology);
_typologyRepository.Save();
}
else
_validatonDictionary.AddError("Name", errorMessageNameUnique);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用MVC 3和View Model,在我的例子中我有一个View Model,它应该显示一个项目列表,还有一个用于插入一些输入的表单.
我的视图中存在问题,因为我无法将表格与视图模型相关联,您能告诉我我做错了什么吗?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using TestGuestBook.Models;
namespace TestGuestBook.ViewModel
{
public class ListAddCommentsViewModel
{
public int CommentId { get; set; }
[Required]
public string Nominative { get; set; }
[Email]
public string Email { get; set; }
[Required]
public string Content { get; set; }
public List<Comment> CommentItems { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
视图
@model IEnumerable<TestGuestBook.ViewModel.ListAddCommentsViewModel>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>ListAddCommentsViewModel</legend>
<div …Run Code Online (Sandbox Code Playgroud) 您好,我需要在工具栏中添加一个简单的文本,该文本应该位于工具栏内声明的两个按钮之间,您知道该怎么做吗?请让我知道,谢谢
我需要分析一下用C Sharp制作的Windows服务,我想知道Windows 7 Professional中是否有任何工具允许它.或者一些易于设置的免费应用程序.
谢谢你的时间.
c# ×5
asp.net ×2
asp.net-mvc ×2
html ×2
c#-4.0 ×1
css ×1
extjs ×1
linq ×1
performance ×1
sencha-touch ×1
sql ×1
viewmodel ×1
web-config ×1