默认的ASP.NET MVC 3项目模板包含以下IgnoreRoute指令:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
Run Code Online (Sandbox Code Playgroud)
我现在看到多个项目改变了这一行(包括StackExchange的DataExplorer),而不是看起来像:
routes.IgnoreRoute("{*allaxd}", new {allaxd = @".*\.axd(/.*)?"});
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释在什么情况下或一般情况下为什么默认.axd路由忽略不适合后一个版本? 或者反过来说,为什么人们会选择不使用后一个版本而只是坚持默认?
我需要开发一个信息亭系统.唯一的付款方式是信用卡/借记卡.自助服务终端需要与另一台PC联网.例如,如果客户在售货亭上订购了某些东西,则需要将其发送到另一台商店,员工可以看到订购的商品.
以下是我的以下解决方案:
选项1)基于Web的应用程序
使用FLASH,ASP.net或JAVA作为用户界面?
如果我采取这种方式,我如何与信用卡/借记卡读卡器通信?读卡器将安装在自助服务终端上,但自助服务终端软件将在网络上.我是否必须创建一个安全的连接来与读者进行通信?
选项2)在自助服务终端上创建应用程序
使用FLASH,JAVA,Windows表示层与.NET?
如何与读卡器通信?
哪个选项最好?1还是2?JAVA,FLASH?WINDOWs .net?那个linux怎么样?开发自助服务终端是否容易?
谢谢您的帮助.
我有一个在Maven中构建的gwt应用程序,现在我尝试运行一个简单的GWT测试,如下:
public class GwtTestLaughter extends GWTTestCase {
/**
* Specifies a module to use when running this test case. The returned
* module must include the source for this class.
*
* @see com.google.gwt.junit.client.GWTTestCase#getModuleName()
*/
@Override
public String getModuleName() {
return "com.sample.services.joker.laughter.Laughter";
}
/**
* Add as many tests as you like
*/
public void testSimple() {
assertTrue(true);
}
}
Run Code Online (Sandbox Code Playgroud)
在pom.xml文件中,配置gwt-maven-plugin和maven-surefire-plugin如下:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.1.0-1</version>
<configuration>
<!-- Use the 'war' directory for GWT hosted mode -->
<output>${basedir}/war</output>
<webXml>${basedir}/war/WEB-INF/web.xml</webXml>
<runTarget>index.html</runTarget>
<!-- …Run Code Online (Sandbox Code Playgroud) 是否有一个函数可以搜索某个子字符串的最后一次出现并返回它的索引?
例如,如果我想\在文件路径中搜索char' ' 的最后一次出现' C:\Program Files\Microsoft'.
我目前正在使用GET获取有关文件的信息,如果我使用HEAD请求重写它会更快吗?原因我在第一次响应后关闭连接.
我试图构建一个ASP.NET Core 1.1 Controller方法来处理如下所示的HTTP请求:
POST https://localhost/api/data/upload HTTP/1.1
Content-Type: multipart/form-data; boundary=--------------------------625450203542273177701444
Host: localhost
Content-Length: 474
----------------------------625450203542273177701444
Content-Disposition: form-data; name="file"; filename="myfile.txt"
Content-Type: text/plain
<< Contents of my file >>
----------------------------625450203542273177701444
Content-Disposition: form-data; name="text"
Content-Type: application/json
{"md5":"595f44fec1e92a71d3e9e77456ba80d0","sessionIds":["123","abc"]}
----------------------------625450203542273177701444--
Run Code Online (Sandbox Code Playgroud)
这是一个multipart/form-data请求,一部分是(小)文件,另一部分是基于提供的规范的json blob。
理想情况下,我希望控制器方法如下所示:
POST https://localhost/api/data/upload HTTP/1.1
Content-Type: multipart/form-data; boundary=--------------------------625450203542273177701444
Host: localhost
Content-Length: 474
----------------------------625450203542273177701444
Content-Disposition: form-data; name="file"; filename="myfile.txt"
Content-Type: text/plain
<< Contents of my file >>
----------------------------625450203542273177701444
Content-Disposition: form-data; name="text"
Content-Type: application/json
{"md5":"595f44fec1e92a71d3e9e77456ba80d0","sessionIds":["123","abc"]}
----------------------------625450203542273177701444--
Run Code Online (Sandbox Code Playgroud)
但是,a,这不仅仅适用于{TM}。当我有这样的东西时,IFormFile 确实会填充,但是json字符串不会反序列化为其他属性。
我还尝试向其中添加除以外的所有属性的Text属性UploadPayload,该属性 …
我正在通过NuGet(pkg版本0.3.0)使用WCF WebApi堆栈(预览4),似乎无法弄清楚如何使用"POST a POCO" HttpClient.
鉴于以下内容:
Public Class MyInfo
Public Property MyDate As DateTime
Public Property MyId As Guid
End Class
...
Dim value = New MyInfo With {.MyDate = Today, .MyId = Guid.NewGuid()}
Using client as New HttpClient(baseUri)
Using response = client.Post(requestUri, New ObjectContent(Of MyInfo)(value))
' Do stuff
End Using
End Using
...
Run Code Online (Sandbox Code Playgroud)
Post调用该方法时,我得到以下异常:
The 'XmlSerializer' serializer cannot serialize the type 'MyInfo'.
at Microsoft.ApplicationServer.Http.XmlMediaTypeFormatter.GetSerializerForType(Type type)
at Microsoft.ApplicationServer.Http.XmlMediaTypeFormatter.OnWriteToStream(Type type, Object value, Stream stream, HttpContentHeaders contentHeaders, TransportContext context)
at …Run Code Online (Sandbox Code Playgroud) 我已经为我一直在研究的ASP.NET MVC3站点构建了一个通知系统,让用户知道他们执行的各种操作成功发生了("拍拍背"消息).解决方案效果很好,但我有一个问题,我很乐意解决,但我似乎无法解决如何做到这一点.
在控制器中,我有以下示例操作方法:
<HttpGet()>
Public Function Edit(id As Guid) As ActionResult
Return View(GetMyViewModel(id))
End Function
<HttpPost()>
Public Function Edit(...) As ActionResult
' Save updated ... information
Me.TempData("UserMessage") = "Data Saved! You are truly an awesome user!"
' PRG back to Edit
Return RedirectToAction("Edit")
End Function
Run Code Online (Sandbox Code Playgroud)
然后在我的视图(剃刀布局)中,我有代码来查找集合中"UserMessage"密钥的存在TempData,如果它存在,我构建了一些JavaScript来为用户呈现类似于咆哮的通知:
/* This only exists when we have something to show */
$(function () {
showNotification([the message from TempData]);
});
Run Code Online (Sandbox Code Playgroud)
然后,类似咆哮的消息要么随着时间消失,要么用户可以点击消息来消除它.
到目前为止一切顺利,一切都按预期工作.用户POST Edit,他们被RPG回来Edit,咆哮的" 数据保存!你真是一个真棒用户! "消息显示和解雇.
如果用户然后导航到另一个页面,然后点击浏览器的后退按钮,则浏览器会深入到其缓存中,导致浏览器执行相同的javascript,向用户显示相同的" 数据已保存!您真是一个非常棒的用户! "消息再次.这让用户感到困惑,认为通过单击后退按钮,他们只是做了一些导致又一次保存的事情(或者无论消息是什么). …
我在ASP.Net MVC中使用NHibernate和ninject,使用此页面作为指南.我认为有一点奇怪的是,在这段代码中(页面的一半)
public class RepositoryModule : NinjectModule
{
public override void Load()
{
const string connectionString = @"Server=localhost; Port=3306; Database=trucktracker; Uid=root; Pwd='your_own_password';";
NHibernateHelper helper = new NHibernateHelper(connectionString);
Bind<ISessionFactory>().ToConstant(helper.SessionFactory).InSingletonScope();
Bind<IUnitOfWork>().To<UnitOfWork>().InRequestScope();
Bind<ISession>().ToProvider(new SessionProvider()).InRequestScope();
Bind<IIntKeyedRepository<Truck>>().To<Repository<Truck>>().InRequestScope();
}
}
Run Code Online (Sandbox Code Playgroud)
我认为你需要为每个型号设置这条线是很奇怪的:
Bind<IIntKeyedRepository<Truck>>().To<Repository<Truck>>().InRequestScope();
Run Code Online (Sandbox Code Playgroud)
如果我有100个不同的表(以及模型),我真的需要为我拥有的每个类添加这一行吗?有没有更好的方法我只能声明一次并使用继承来传入我的控制器中的Type?
.net ×2
asp.net-mvc ×2
asp.net-core ×1
cardreader ×1
credit-card ×1
gwt ×1
http-get ×1
http-head ×1
http-verbs ×1
ignoreroute ×1
java ×1
javascript ×1
junit ×1
kiosk ×1
maven ×1
ms-word ×1
nhibernate ×1
ninject ×1
pdf ×1
vb.net ×1
wcf ×1
wcf-client ×1
wcf-web-api ×1