是否有一种简单的方法可以将字符串的第一个字母大写并降低其余部分?是否有内置方法或我需要自己制作?
使用C#,我需要一个名为User具有用户名,密码,活动标志,名字,姓氏,全名等的类.
应该有方法来验证和保存用户.我只是为这些方法编写测试吗?我甚至需要担心测试属性,因为它们是.Net的getter和setter?
我有一些代码可以在我们的系统中保存一张票.如果有错误,它会执行RedirectToAction.问题是我似乎没有在新动作中出现错误.我怎样才能解决这个问题?
ModelState.AddModelError("_FORM", "Unable to save ticket");
ModelState.AddModelError("_FORM", "Phone number was invalid.");
ModelState.AddModelError("_FORM", "Lane number is required.");
return RedirectToAction("CreateStep", "Ticket");
Run Code Online (Sandbox Code Playgroud)
我知道有人建议使用TempData,但是如何从ModelState中获取每个错误?
谢谢.
我有一个Windows服务并使用nlog进行日志记录.当我从visual studio ide运行时,一切正常.日志文件更新没有问题.当我安装该服务时,该服务运行正常,但日志文件永远不会更新.如果有帮助,我在LOCAL SERVICE下运行.是的,我在我的应用程序文件夹下创建了logs目录.
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<targets>
<target name="file" xsi:type="File" fileName="${basedir}/logs/${shortdate}_info.txt"
layout="${date} ${logger} ${message}" />
</targets>
<rules>
<logger name="*" minlevel="Info" maxlevel="Info" writeTo="file" />
</rules>
</nlog>
Run Code Online (Sandbox Code Playgroud) 我已经实现了Scott Hanselman的方法来跟上web.config的dev/qa/prod版本:http://www.hanselman.com/blog/CommentView.aspx? guid = 93bfa4b3-44cd-4681-b70e-f4a2b0386466
由于某种原因,当我编译我的项目时,我在输出窗口中收到此错误消息.
有任何想法吗?
------ Build started: Project: ABC.Flims.Web, Configuration: Development Any CPU ------
"C:\Projects\ballyhoo-trunk\src\ABC.Flims.Web\scripts/copyifnewer.bat" "C:\Projects\ballyhoo-trunk\src\ABC.Flims.Web\web.config.Development" "C:\Projects\ballyhoo-trunk\src\ABC.Flims.Web\web.config"
'???@echo' is not recognized as an internal or external command,
operable program or batch file.
Run Code Online (Sandbox Code Playgroud)
这是脚本文件:
@echo off
echo Comparing two files: %1 with %2
if not exist %1 goto File1NotFound
if not exist %2 goto File2NotFound
fc %1 %2
if %ERRORLEVEL%==0 GOTO NoCopy
echo Files are not the same. Copying %1 over %2
copy %1 %2 …Run Code Online (Sandbox Code Playgroud) 我有一个控制器根据用户类型加载一些下拉菜单.例如:
public ActionResult Index()
{
switch (SessionHelper.ViewLimit)
{
case "C":
ViewData["CustDivision"] = LoadCustDivisions();
ViewData["Customer"] = LoadCustomers();
break;
case "P":
ViewData["Customer"] = LoadCustomers();
ViewData["Employee"] = LoadEmployees();
break;
case "D":
ViewData["Customer"] = LoadCustomers();
ViewData["Division"] = LoadDivisions();
break;
default:
return RedirectToAction("Logout", "Account");
}
return View()
}
Run Code Online (Sandbox Code Playgroud)
首先,switch语句是否属于控制器,如果是,那么我应该在哪里放置LoadCustomers(),LoadDivisions(),LoadEmployees()?
他们都做同样的事情.一种方式更好吗?显然,如果我编写代码,我会知道我做了什么,但其他人如何阅读呢?
if (!String.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
return RedirectToAction("Open", "ServiceCall");
Run Code Online (Sandbox Code Playgroud)
要么
if (!String.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Open", "ServiceCall");
}
Run Code Online (Sandbox Code Playgroud) 我没有设置构建我的ASP.NET MVC项目,它在本地工作正常.我将nant添加到tools文件夹并将其添加到版本控制.TeamCity获取我的更改并启动构建但它失败了.
我相信我使用的是最新版本的Nant,我已将.net framework 3.5添加到nant.exe.config中.我在服务器上缺少什么,是的.net框架是安装在服务器上的,因为如果我在那里手动构建和部署asp.net mvc应用程序吗?
构建文件如下:
<target name="compile" description="Compiles using the AutomatedDebug Configuration">
<msbuild project="Tolt.Sims.sln" />
</target>
Run Code Online (Sandbox Code Playgroud)
这是错误:
BUILD FAILED Failed to initialize the 'Microsoft .NET Framework 2.0' (net-2.0) target framework.
Property evaluation failed. Expression: ${path::combine(sdkInstallRoot, 'bin')} ^^^^^^^^^^^^^^ Property 'sdkInstallRoot' has not been set.
For more information regarding the cause of the build failure, run the build again in debug mode. Try 'nant -help' for more information
我有一个asp.net mvc应用程序,现在我需要添加一个Web服务来配合它.什么是最好的解决方案?只需创建一个新的Web服务项目并将其添加到我的解决方案,然后使用不同的URL将其部署到同一个Web服务器?我希望它只是mvc应用程序的一部分,因为我有我所有的数据库代码.
任何建议,将不胜感激.谢谢.
我试图检索一个对象的公共属性,但它什么也没有返回.你能告诉我我做错了吗?
public class AdHocCallReportViewModel : ReportViewModel
{
public string OperatorForCustEquipID { get; set; }
public string OperatorForPriorityID { get; set; }
public string OperatorForCallTypeID { get; set; }
public string OperatorForStatusID { get; set; }
}
public UpdateReportParameters(AdHocCallReportViewModel rvm)
{
var type = rvm.GetType();
foreach (var f in type.GetFields().Where(f => f.IsPublic))
{
Console.WriteLine(f.Name);
Console.WriteLine(f.GetValue(rvm).ToString());
}
}
Run Code Online (Sandbox Code Playgroud)
单步执行代码时,它会跳过foreach循环,因为GetFields返回零项.
c# ×8
asp.net-mvc ×4
asp.net ×3
capitalize ×1
coding-style ×1
logging ×1
nant ×1
nlog ×1
service ×1
string ×1
tdd ×1
teamcity ×1
unit-testing ×1
web-services ×1