我只是想知道如何实现asp.net mvc3应用程序的通知系统,就像用户登录到系统成功登录页面时显示消息,如果没有错误消息.
我有一些方法,上面的问题保持viewmodel上的属性值,但不知道如何将通知从一个控制器传递到另一个控制器或从一个操作传递到另一个操作.
就像当我们从帐户控制器登录到系统登录成功消息到家庭控制器并在主页上显示通知消息用户登录成功.
请您理解是否可以提供代码示例或一些最佳方法来解决上述问题.
Thnaks
PS
这是我正在尝试的一些代码片段
public ActionResult Register(UserRegistrationViewModel registrationModel)
{
//some logic and when end of the code set the error message and
//redirect to separate action and after new action can read the message and show
if(success)
return RedirectToAction("Index","Home");
else
return RedirectToAction("Logon");
}
Run Code Online (Sandbox Code Playgroud) 对于多个消息和成功/失败,是否有通知模式的替代方案?
我有一个类OperationResult,我用它来返回一个Success布尔值和一个"错误"消息列表.这些消息有时是意外错误,但更常见的是经常发生的普通情况.有时我们返回单个错误消息,但有时我们返回几个.我希望找到一个更好的方法.
这似乎或多或少是福勒倡导的通知模式.然后,消费者对成功状态和错误做一些合理的事情,通常向用户显示错误,但有时在非致命错误的情况下继续.
因此,我有很多服务方法(不是Web服务方法),看起来像这样:
private ThingRepository _repository;
public OperationResult Update(MyThing thing)
{
var result = new OperationResult() { Success = true };
if (thing.Id == null) {
result.AddError("Could not find ID of the thing update.");
return result;
}
OtherThing original = _repository.GetOtherThing(thing.Id);
if (original == null) return result;
if (AnyPropertyDiffers(thing, original))
{
result.Merge(UpdateThing(thing, original));
}
if (result.Success) result.Merge(UpdateThingChildren(thing));
if (!result.HasChanges) return result;
OperationResult recalcResult = _repository.Recalculate(thing);
if (recalcResult.Success) return result;
result.AddErrors(recalcResult.Errors);
return result;
}
private OperationResult …Run Code Online (Sandbox Code Playgroud) 让我疯狂的信息是ORA-01008 - Not all variables bound.
有没有办法知道我拼错了42个可能的变量名中的哪一个,而不是盯着显示器直到我的眼睛弹出来?
更新:我ADO.NET用来访问数据库.正如@Justin Cave建议的那样,它可能会丢失Oracle异常中的一些信息.但我很肯定参数名称即使在SQL Plus中也不会出现.
有没有办法在编译期间显示的代码中嵌入消息,当编译该代码时?消息本质上是诊断性的,不应修改或中止编译过程.
(免责声明:我知道这个问题的答案.我没有在Stack Overflow上找到它,我认为这对知识库来说是一个有用的补充.)
我正在编写应用程序,它建立shell钩子来获取shell事件(如果重要的话,我正在使用C#).我正在使用这个例子:http://msbob.spaces.live.com/blog/cns!DAFD19BC5D669D8F!1,332.entry
Hook工作正常但我没有收到我感兴趣的消息:HSHELL_WINDOWACTIVATED(所有其他与窗口相关的事件都运行良好).相反,我收到的代码为32772的消息应该是HSHELL_RUDEAPPACTIVATED(有些谷歌搜索有帮助).
但是我无法理解为什么我根本没有收到HSHELL_WINDOWACTIVATED以及HSHELL_RUDEAPPACTIVATED消息的含义.MSDN没有提及它.任何人都可以向我解释一下吗?
我在独立的Java应用程序中使用Spring IoC.应用程序启动时,它会创建一个包含启动信息的日志.我不明白的一些消息,请帮助我理解它们并解释如果必须修复它们如何修复它们?我也很好奇:由于这些消息,我的应用程序稳定性是否有任何危险?
吓唬我的消息以单词"Unable"开头.目前该应用程序运行良好.
INFO - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@52cc95d: startup date [Thu Jun 02 16:02:12 MSD 2011]; root of context hierarchy
INFO - Loading XML bean definitions from class path resource [application-config.xml]
DEBUG - Using JAXP provider [com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl]
DEBUG - Loading schema mappings from [META-INF/spring.schemas]
DEBUG - Loaded schema mappings: {http://www.springframework.org/schema/tx/spring-tx-2.5.xsd=org/springframework/transaction/config/spring-tx-2.5.xsd, http://www.springframework.org/schema/tx/spring-tx-2.0.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/tx/spring-tx.xsd=org/springframework/transaction/config/spring-tx-3.0.xsd, http://www.springframework.org/schema/tx/spring-tx-3.0.xsd=org/springframework/transaction/config/spring-tx-3.0.xsd}
DEBUG - Loading bean definitions
DEBUG - Loaded 3 bean definitions from location pattern [application-config.xml]
DEBUG - Bean factory for org.springframework.context.support.ClassPathXmlApplicationContext@52cc95d: org.springframework.beans.factory.support.DefaultListableBeanFactory@33aae94f: defining beans [propertyPlaceholderConfigurer,dbWorker,connectionPool]; root of factory …Run Code Online (Sandbox Code Playgroud) 我目前正在研究另一种查看线程和消息的方法.但我在弄清楚如何显示附加到邮件的图像时遇到了问题.
我对此网址有一个GET请求:https://graph.facebook.com/t_id.T_ID/messages?access_token=ACCESS_TOKEN.响应包括
"attachments": {
"data": [
{
"id": "df732cf372bf07f29030b5d44313038c",
"mime_type": "image/jpeg",
"name": "image.jpg",
"size": 76321
}
]
}
Run Code Online (Sandbox Code Playgroud)
但我找不到任何方式来访问图像.
谢谢
每次我尝试在IntelliJ中运行测试或编译代码时,如果另一个文件有编译错误,它会导致消息窗口自动弹出,编辑器会自动打开该文件并显示错误.有没有办法防止这种行为?
有谁知道如何使用applescript/osascript发送群组消息?我尝试过很多东西,但似乎没什么用.
我正在尝试以编程方式通过我自己的网站登录Instagram,因为我想从Instagram检索直接消息(这需要登录,因为它尚未在Instagram API中支持).但Instagram登录页面需要cookie才能登录.
我不断收到无法加载页面的消息,以及我可能需要启用cookie.
有没有办法通过PHP以编程方式登录到Instagram?
这就是我到目前为止所拥有的.
$ch = curl_init('https://instagram.com/accounts/login/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$result = curl_exec($ch);
preg_match_all('/^Set-Cookie:\s*([^\r\n]*)/mi', $result, $ms);
$cookies = array();
foreach ($ms[1] as $m) {
list($name, $value) = explode('=', $m, 2);
$cookies[$name] = $value;
}
$ccode = substr($cookies['ccode'], 0, 2);
$mid = array_shift(explode(';', $cookies['mid']));
$csfrtoken = array_shift(explode(';', $cookies['csrftoken']));
$header = array();
$header[] = 'Accept: */*';
$header[] = 'Accept-Encoding: gzip,deflate';
$header[] = 'Accept-Language: nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4';
$header[] = 'Connection: keep-alive';
$header[] = 'Content-Length: 46';
$header[] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8';
$header[] …Run Code Online (Sandbox Code Playgroud) messages ×10
c# ×3
ado.net ×1
applescript ×1
asp.net ×1
asp.net-mvc ×1
attachment ×1
cookies ×1
directive ×1
imessage ×1
instagram ×1
macos ×1
oop ×1
oracle ×1
osascript ×1
php ×1
preprocessor ×1
return ×1
shell ×1
spring ×1
spring-jdbc ×1
visual-c++ ×1
winapi ×1