How to serve favicon.ico and robots.txt files from ASP.NET MVC3 application -
asp.net mvc3 application hosted in apache in mono virtual host address http://www.mysite.com
requests files robots.txt , favicon.ico , apple-touch-icon.png cause 404 error below since there no mvc3 controllers names. how server files ? it possible force apache serve them regular files or can force mvc3 application return files ? proper way implement ?
system.web.httpexception: controller path '/robots.txt' not found or not implement icontroller. @ system.web.mvc.defaultcontrollerfactory.getcontrollerinstance (system.web.routing.requestcontext requestcontext, system.type controllertype) [0x00000] in <filename unknown>:0 @ system.web.mvc.defaultcontrollerfactory.createcontroller (system.web.routing.requestcontext requestcontext, system.string controllername) [0x00000] in <filename unknown>:0 @ system.web.mvc.mvchandler.processrequestinit (system.web.httpcontextbase httpcontext, icontroller& controller, icontrollerfactory& factory) [0x00000] in <filename unknown>:0 @ system.web.mvc.mvchandler+<>c__displayclass6.<beginprocessrequest>b__2 () [0x00000] in <filename unknown>:0 @ system.web.mvc.securityutil+<>c__displayclassb`1[system.iasyncresult].<processinapplicationtrust>b__a () [0x00000] in <filename unknown>:0 @ system.web.mvc.securityutil.<getcallinapptrustthunk>b__0 (system.action f) [0x00000] in <filename unknown>:0 @ system.web.mvc.securityutil.processinapplicationtrust (system.action action) [0x00000] in <filename unknown>:0 @ system.web.mvc.securityutil.processinapplicationtrust[iasyncresult] (system.func`1 func) [0x00000] in <filename unknown>:0 @ system.web.mvc.mvchandler.beginprocessrequest (system.web.httpcontextbase httpcontext, system.asynccallback callback, system.object state) [0x00000] in <filename unknown>:0 @ system.web.mvc.mvchandler.beginprocessrequest (system.web.httpcontext httpcontext, system.asynccallback callback, system.object state) [0x00000] in <filename unknown>:0 @ system.web.mvc.mvchandler.system.web.ihttpasynchandler.beginprocessrequest (system.web.httpcontext context, system.asynccallback cb, system.object extradata) [0x00000] in <filename unknown>:0 @ system.web.httpapplication+<pipeline>c__iterator3.movenext () [0x00000] in <filename unknown>:0 @ system.web.httpapplication.tick () [0x00000] in <filename unknown>:0
fixing robots.txt:
right click project name , select "add->new item"
choose "text file" , call "robots.txt"
can leave file blank
fixing favicon.ico:
go registerroutes method of global.asax.cs file , add near top: can @ page more info: favicon icon-mvc3 asp.net
routes.ignoreroute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
fixing apple-touch-icon.png:
look @ these websites
why getting error apple-touch-icon-precomposed.png
http://mathiasbynens.be/notes/touch-icons
Comments
Post a Comment