我在Windows Server 2008上的IIS 7上运行ASP.NET 3.5 Web应用程序.
我今天下午早些时候收到了以下错误:
HTTP Error 503. The service is unavailable.
我查看了事件日志并发现:
A process serving application pool 'Classic .NET AppPool' suffered a fatal communication error with the Windows Process Activation Service. The process id was '3328'. The data field contains the error number.
以下是该活动的全部细节:
Log Name: System
Source: Microsoft-Windows-WAS
Date: 18/09/2009 14:58:31
Event ID: 5011
Task Category: None
Level: Warning
Keywords: Classic
User: N/A
Computer: computername
Description:
A process serving application pool 'Classic .NET AppPool' suffered a …Run Code Online (Sandbox Code Playgroud) 我使用Visual Studio 2008和SQL Server 2008在C#ASP.NET上工作了7个月.
今天,我正在运行以前运行的应用程序的一部分,我收到以下错误:
对象'地址',数据库'CNET_85731',架构'dbo'上的SELECT权限被拒绝.
我浏览了我的代码并发现此错误是由以下用户控件引起的:
protected void sdsAddressesList_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
if (e.AffectedRows == 0)
{
ddlAddresses.Items.Insert((0), new ListItem("No Billing Addresses", "0"));
}
}
Run Code Online (Sandbox Code Playgroud)
SQLDataSource定义如下:
<asp:SqlDataSource ID="sdsAddressesList" runat="server" OnSelecting="sdsAddressesList_Selecting" OnSelected="sdsAddressesList_Selected"
SelectCommand="SELECT [AddressId], [ZipPostalCode], ZipPostalCode + ' -- ' + Address1 AS CombinedAddress FROM [Address] WHERE ([CustomerID] = @CustomerID AND [IsBillingAddress] = @IsBillingAddress) ORDER BY [ZipPostalCode]"
ConnectionString="<%$ ConnectionStrings:eCoSysConnection %>">
<SelectParameters>
<asp:Parameter Name="CustomerID" Type="Int32" />
<asp:Parameter Name="IsBillingAddress" Type="Boolean" />
</SelectParameters>
</asp:SqlDataSource>
Run Code Online (Sandbox Code Playgroud)
基本上,控件执行的操作是从[Address]表中检索登录用户的地址列表,然后填充下拉列表ddlAddresses.
Address表具有与数据库中其余表相同的权限.我有大约60个表和大约200个存储过程都快乐地做SELECTs等工作.没问题.除了这一个问题.到底是怎么回事?我没有对数据库或表权限进行任何更改.
任何人都可以帮助我.
问候
沃尔特
我正在使用ASP.NET Identity 2.0与ASP.NET MVC 5和EF 6项目.
我正在尝试编辑与用户关联的角色.
在我的useradmin控制器中,我有:
//
// GET: /Users/Edit/1
public async Task<ActionResult> Edit(string id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
var user = await UserManager.FindByIdAsync(id);
if (user == null)
{
return HttpNotFound();
}
var userRoles = await UserManager.GetRolesAsync(user.Id);
return View(new EditUserViewModel()
{
Id = user.Id,
Email = user.Email,
RolesList = RoleManager.Roles.ToList().Select(x => new SelectListItem()
{
Selected = userRoles.Contains(x.Name),
Text = x.Name,
Value = x.Name
})
});
}
Run Code Online (Sandbox Code Playgroud)
我收到了错误
'你调用的对象是空的.'
在线:
return View(new EditUserViewModel() …Run Code Online (Sandbox Code Playgroud) 我目前正在使用ASP.NET 3.5和SQLServer 2008开发在线拍卖系统.我已经达到了开发的地步,我需要确保我的系统能够合理地处理在以下情况下可能出现的并发问题:
两个人 - 杰拉尔丁和约翰 - 想要竞标相同的拍卖品,目前价格为50英镑.Geraldine以55英镑的价格出价,而约翰则出价52英镑.系统现在有两个页面'submit_bid.aspx'正在运行; 页面的每个副本都会检查他们的出价是否足够高,他们都看到了,并且他们提交了出价.如果约翰的出价首先出现,那么拍卖品的价格目前是55英镑,过了一会儿,它被52英镑的出价所取代.
我需要做的是锁定拍卖项目行,直到当前的出价价格被更新,然后允许任何其他出价者检查当前出价并设置新的出价.
我的问题是:使用T-SQL和/或ADO.NET这样做的最佳实践方法是什么?
我目前有一个AuctionItem表,其中包含以下字段(以及我为简洁起见未包含的其他字段):
AuctionItemID INT
CurrentBidPrice MONEY
CurrentBidderID INT
Run Code Online (Sandbox Code Playgroud)
我已经进行了一些研究,并提出了以下T-SQL(伪代码):
@Bid MONEY
@AuctionItemID INT
BEGIN TRANSACTION
SELECT @CurrentBidPrice = CurrentBidPrice
FROM AuctionItem
WITH (HOLDLOCK, ROWLOCK)
WHERE AuctionItemID = @AuctionItemID
/* Do checking for end of Auction, etc. */
if (@Bid > @CurrentBidPrice)
BEGIN
UPDATE AuctionItem
SET CurrentBidPrice = @Bid
WHERE AuctionItemID = @AuctionItemID
END
COMMIT TRANSACTION
Run Code Online (Sandbox Code Playgroud)
我还读过,如果我包括SET LOCK_TIMEOUT我也可以减少失败的并发更新次数.例如:
SET LOCK_TIMEOUT 1000
Run Code Online (Sandbox Code Playgroud)
...将使并发更新等待1000毫秒以释放锁.这是最佳做法吗?
我目前正在使用ASP.NET,jQuery和JSON实现客户端分页解决方案.
我一直在关注来自encosia的优秀文章:http://encosia.com/2008/08/20/easily-build-powerful-client-side-ajax-paging-using-jquery/
在我的Web方法中,我将数据从数据库中检索为DataTable:
DataTable categoryProducts = ProductViewerAccess.GetCategoryProducts
("AA", 4, 0, Page.ToString(), out howManyPages, "FALSE", 0, "CostPrice", "asc", destinationList);
Run Code Online (Sandbox Code Playgroud)
然后,我将DataTable中的数据检索为匿名类型:
var feeds =
from feed in categoryProducts.AsEnumerable()
select new
{
Description = feed.Field<string>("description"),
MfPartNo = feed.Field<string>("MfPN"),
Inventory = feed.Field<Int32>("Inventory")
};
Run Code Online (Sandbox Code Playgroud)
然后,匿名类型从Web方法返回到客户端:
return feeds.Take(PageSize);
然后,模板将提取并显示字段:
<tbody>
{#foreach $T.d as post}
<tr>
<td>
{$T.post.Description}
<p>Mfr#: {$T.post.MfPartNo}</p>
</td>
<td>{$T.post.Inventory}</td>
</tr>
{#/for}
</tbody>
Run Code Online (Sandbox Code Playgroud)
一切都很好.
但是,我想扩展代码以执行一些评估检查(例如,检查DataTable中的各个列不是NULL)和其他预处理(例如,调用各种函数来构建基于图像ID的图像URL - 在将DataTable的结果行作为匿名类型返回给客户端之前,这是DataTable中未显示在代码片段中的另一列.
基本上,我想迭代DataTable,执行评估检查和预处理,同时手动构建我的匿名类型.或者也许有更好的方法来实现这一目标?
无论如何我能做到这一点吗?
亲切的问候
沃尔特
我正在ASP.NET 3.5和IIS 7中开发一个应用程序.我编写了一个HTTP模块来执行URL重写,例如,我想将用户名重写为帐户ID"〜/ Profiles/profile.aspx?AccountID =" + account.AccountID.ToString();
见下文:
使用系统; 使用System.Collections.Generic; 使用System.Data; 使用System.Configuration; 使用System.IO; 使用System.Linq; 使用System.Web; 使用System.Web.Security; 使用System.Web.UI; 使用System.Web.UI.HtmlControls; 使用System.Web.UI.WebControls; 使用System.Web.UI.WebControls.WebParts; 使用System.Xml.Linq;
public class UrlRewrite : IHttpModule
{
private AccountRepository _accountRepository;
private WebContext _webContext;
public UrlRewrite()
{
_accountRepository = new AccountRepository();
_webContext = new WebContext();
}
public void Init(HttpApplication application)
{
// Register event handler.
application.PostResolveRequestCache +=
(new EventHandler(this.Application_OnAfterProcess));
}
public void Dispose()
{
}
private void Application_OnAfterProcess(object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
string[] …Run Code Online (Sandbox Code Playgroud) 我试图在SQL Server 2008中使用BULK INSERT导入TSV(制表符分隔值)文件.
这是我的脚本:
USE ABC
GO
CREATE TABLE CSVTest
(ID INT,
FirstName VARCHAR(40),
LastName VARCHAR(40),
TodaysDate DATETIME)
GO
BULK
INSERT CSVTest
FROM 'd:\csvtest.txt'
WITH
(
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\n'
)
GO
--Check the content of the table.
SELECT *
FROM CSVTest
GO
--Drop the table to clean up database.
SELECT *
FROM CSVTest
GO
DROP TABLE CSVTest
GO
Run Code Online (Sandbox Code Playgroud)
这是文件的内容d:\csvtest.txt:
1 James Smith 16/10/2010 04:45:35 2 Meggie Smith 16/10/2010 04:45:35 3 Robert Smith 16/10/2010 04:45:35 …
asp.net ×2
c# ×2
http ×2
iis-7 ×2
asp.net-3.5 ×1
asp.net-mvc ×1
bulk ×1
concurrency ×1
httpmodule ×1
insert ×1
sql ×1
sql-server ×1
t-sql ×1