Why Web API 2 has RouteConfig.cs file?
I m working on Web API project, and it is using WebApiConfig.cs file
to defined routs for Web API.
Web API fold RouteConfig.cs file.
I have googled and they say RouteConfig.cs is
for MVC routing. It is actually a confusing statement. Can you please guide why WebAPI has RouteConfig.cs file
? Why would one need MVC routing in Web API ? What function it will do ?
Thanks for your help and guidance.
The RouteConfig.cs file
isn't required for Web API. It is included by default in new Web API projects because that template also includes an MVC webpage (for the index page that appears when you open the project in a browser).
If you delete both the RouteConfig.cs and
the HomeController.cs file
(as well as modify Global.asax.cs to
not call RouteConfig.RegisterRoutes()),
then your project will still compile and the API controllers will still work fine, you will just be missing a pretty homepage.
Note also that MVC Areas have their own MVC routing and do not use the global MVC routing, which is why the /Help page
still works even when RouteConfig.cs has
been removed.
Similar Messages
-
Re: Can't load web app that has sealed jar files
I forgot to mention that I'm using WebLogic Server 6.1 with
J2EE 1.2 Plus Additional J2EE 1.3 Features.
Barry
"Barry" <[email protected]> wrote:
>
>I am getting the error "String index out of range: -1" thrown by
>weblogic.servlet.internal.WebAppHelper.resolveManifestName when I start
>WLS. The
>problem seems to be
>with certain jar files in the WEB-INF\lib directory of a particular web
>app. It
>seems that if the manifest in a
>jar file has "Sealed: true", the error occurs. If I remove sealed jars
>from the
>lib directory, the problem goes
>away. The jars in question are xalan.jar and crimson.jar.
>
>Any ideas?
>
>Thanks,
>Barry
>
Yes, it's valid.
Joe Carew wrote:
> I can't find any reference to CR064391 on the support site. Does anyone know if this
> is the valid CR number? I am having this same issue trying to deploy axis.
>
> Rajesh Mirchandani <[email protected]> wrote:
> >contact [email protected] and refer to CR064391.
> >
> >Barry wrote:
> >
> >> I forgot to mention that I'm using WebLogic Server 6.1 with
> >> J2EE 1.2 Plus Additional J2EE 1.3 Features.
> >>
> >> Barry
> >>
> >> "Barry" <[email protected]> wrote:
> >> >
> >> >I am getting the error "String index out of range: -1" thrown by
> >> >weblogic.servlet.internal.WebAppHelper.resolveManifestName when I start
> >> >WLS. The
> >> >problem seems to be
> >> >with certain jar files in the WEB-INF\lib directory of a particular web
> >> >app. It
> >> >seems that if the manifest in a
> >> >jar file has "Sealed: true", the error occurs. If I remove sealed jars
> >> >from the
> >> >lib directory, the problem goes
> >> >away. The jars in question are xalan.jar and crimson.jar.
> >> >
> >> >Any ideas?
> >> >
> >> >Thanks,
> >> >Barry
> >> >
> >
> >--
> >Rajesh Mirchandani
> >Developer Relations Engineer
> >BEA Support
> >
> >
Michael Young
Developer Relations Engineer
BEA Support
-
Can't load web app that has sealed jar files
I am getting the error "String index out of range: -1" thrown by
weblogic.servlet.internal.WebAppHelper.resolveManifestName when I start WLS. The
problem seems to be
with certain jar files in the WEB-INF\lib directory of a particular web app. It
seems that if the manifest in a
jar file has "Sealed: true", the error occurs. If I remove sealed jars from the
lib directory, the problem goes
away. The jars in question are xalan.jar and crimson.jar.
Any ideas?
Thanks,
Barry
I am getting the error "String index out of range: -1" thrown by
weblogic.servlet.internal.WebAppHelper.resolveManifestName when I start WLS. The
problem seems to be
with certain jar files in the WEB-INF\lib directory of a particular web app. It
seems that if the manifest in a
jar file has "Sealed: true", the error occurs. If I remove sealed jars from the
lib directory, the problem goes
away. The jars in question are xalan.jar and crimson.jar.
Any ideas?
Thanks,
Barry
-
New to Oracle, why RMAN full backup has 3 backup files?
vendor set up the Oracle, but I noticed the backup has 3 files each time. not sure why.
A "LIST BACKUP" at the RMAN command line would show the contents of each of the BackupSets, BackupPieces.
When you run a BACKUP, RMAN does show, on-screen or to the log file if you redirect to a log, which datafiles are included in which BackupSet.
When you RESTORE DATABASE or RESTORE ARCHIVELOG RMAN reads the repository and identifies the BackupPieces automatically for each BackupSet . You do not need to specify them. However, if you are restoring a Controlfile, you could specifically identify where you want to restore the controlfile from -- because the default behaviour is to restore only the latest controlfile backup, but you might choose to restore an older controlfile. This can be done with the SET UNTIL clause or RESTORE CONTROLFILE FROM 'nameofbackuppiece' command.
Hemant K Chitale
Edited by: Hemant K Chitale on Apr 5, 2011 9:56 AM -
Hello,
I am specifically trying to call a web api, that has a FromBody.
However, I am trying to do it without having to use libraries (or nuget packages) that I cannot install on CRM of CRM Online.
It seems JSON newtonsoft is big... or I guess I could use my own custom formatter...
But I would love to see if someone has an example for posting to web API, versus an ASMX
ThanksWow I had this awesome thing typed up... and it wouldn't do it then wanted me to verify and then that messed up and I lost it all... Wow..
Anyway
[SOLVED]
Works from Plugin or Workflow activity
Use the Query string to pass things (not the body) or else you have to compress it and you can't use the libraries to DO that in the Sandbox... You CAN do that if you or on premise and do NOT isolate.. Then heck I did everything I wanted but for online
this was it.
You do NOT have to use WebClient, use HttpClient (follow the code below)
WebApi 2.2 is what I used
My signature for Webapi
You do have to clean up the response.. as the string you get back is JSON.. and you cannot use the JSON desieralizer...
Easy fix... just do a replacement of the \ and " to a " " space.. then Trim the result.. bingo a clean string response...
[HttpGet]
Public string MyMethod(string value1, string value2, string value3)
This will parse the query string so USE these are your parameters in your query string or the API will NOT work. ?value1=ddd&&value2=ddd&&value3=aaa
of course make up your own string names
IIS and Apache etc work differently so the AMOUNT of data you can send will differ per platform, per version of platform AND usually you can configure it.. IIS used to be like 2048 by default.. anything beyond that (as a total URL incoming) was truncated..
Not sure now. I know it was configurable
I got it working.. all my points are gone... but it's possible
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm;
using System.Net.Http;
using System.IO;
using System.IO.Compression;
using System.Net.Http.Headers;
using System.Runtime.Serialization.Json;
using System.ServiceModel;
using System.Net;
try
string result = string.Empty;
using (var client = new HttpClient())
client.BaseAddress = new Uri(webapihost);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));
client.Timeout = new TimeSpan(0, 0, 30); ;
client.MaxResponseContentBufferSize = 2000000;
using (HttpResponseMessage response = client.GetAsync(webapihost + apimethod + querystring).Result)
if (response.IsSuccessStatusCode)
result = Decompress(response);
tracingService.Trace("Call Data Value [{0}]", result.ToString());
catch (Exception simple)
throw new InvalidPluginExecutionException("Error with simple HTTPClient x-www-form-urlencoded" + simple.ToString());
private string Decompress(HttpResponseMessage response)
try
switch (response.Content.Headers.ContentEncoding.ToString().ToLower())
case "gzip":
return DecompressGzip(response.Content.ReadAsStreamAsync().Result);
case "deflate":
return Inflate(response.Content.ReadAsStreamAsync().Result);
default:
return response.Content.ReadAsStringAsync().Result;
catch (Exception ex)
throw new Exception("Error decompressing: " + ex.ToString());
private string DecompressGzip(Stream datastream)
try
//Create a new stream
//decompress the original
//get back the string (JSON)
if (datastream != null)
Stream decompressedStream = null;
decompressedStream = new GZipStream(datastream, CompressionMode.Decompress, true);
var streamReader = new StreamReader(decompressedStream);
string stringdata = streamReader.ReadToEnd();
decompressedStream.Dispose();
return stringdata;
else
return string.Empty;
catch (Exception ex)
throw new Exception("Gzip error: " + ex.ToString());
private string Inflate(Stream datastream)
try
if (datastream != null)
Stream decompressedStream = null;
decompressedStream = new DeflateStream(datastream, CompressionMode.Decompress, true);
var streamReader = new StreamReader(decompressedStream);
string stringdata = streamReader.ReadToEnd();
decompressedStream.Dispose();
return stringdata;
else
return string.Empty;
catch (Exception ex)
throw new Exception("Inflate error: " + ex.ToString()); -
I'm encountering this error and not sure how to fix, I'm quite new to vCenter so please bear with me.
I'm trying out vCenter 5.1 with Update Manager 5.1 right now. No license key has been entered and I still have 50 odd days to try it out.
2 ESXi hosts are being managed by this vCenter, and they're both running ESXi 4.0
I'm looking to use Update Manager to try to upgrade the ESXi 4.0 hosts to ESXi 5.1
I downloaded the image file VMware-VIMSetup-all-5.1.0-799735.iso from VMWare website, and is looking to import it using the Update Manager so I can update the ESXi hosts, but I keep on getting the error:
File name: VMware-VIMSetup-all-5.1.0-799735.iso
Failed to transfer data
Error was: A web exception has occurred during file upload
I tried importing it by using vSphere client to connect to vCenter server both remotely and locally, with firewall disabled.
I've read http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1026602
I've disabled firewall, and there is no anti-virus program on the server. I've also restarted the machine several times, to no avail, I didn't reinstall update manager because the whole Windows and VCenter installations are clean from scratch.
I logged into the vSphere Client using Active Directory credentials, and I've made all Domain Admins (which my account is a member of) part of the administrator group on the vCenter server. I can't log in using admin@System-Domain because it tells me I don't have permissions for it, I still haven't really had the chance to figure out why that is and not sure if that makes a difference.
Also, I'm fairly certain I'm using the right image file, as I've burned some DVD's used that image file to upgrade some other ESXi hosts. Unless there's a special image file I need to download?
I'm at lost on what I can do to make it work. Please advise.
Thanks.The ISO file you mentioned is the one for vCenter Server. What you need is the "VMware-VMvisor-Installer-5.1.0-799733.x86_64.iso" (or VMware-VMvisor-Installer-201210001-838463.x86_64.iso) for the ESXi host.
André -
Why can't I open a pdf file on my desktop? I have Adobe Reader and running OS 10.10.1 I keep getting the same message: "Adobe Reader could not open '8pdk_96_4.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)."
I tried that.
I saved the file 8pdk_96_4.pdf to my desktop and tried to open it using Adobe Reader but I get the same message: Adobe Reader could not open '8pdk_96_4.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded). -
why would my customer reading my pdf file get this message: 'Licensing for this product has stopped'?
The message goes on to say, 'you cannot use this product at this time. You must repair the problem by uninstalling and then reinstalling this product or contacting your IT administrator or Adobe customer support for help.'Hi sivey@pdx,
Can you please let us know the following:
- Operating System installed;
- Name and version of the Adobe Product (Adobe Reader or Adobe Acrobat);
- Screenshot of the error message. -
On any web sight that has short moves of anytype there is NO SOUND why ???
when I go to any web sight and try to hear a move of any type, there is NO sound. Why???
QuickTime expects video files with separate video and audio tracks, but many MPEG formats used a muxed (multiplexed) single track that contains both. Therefore, iTunes & the iPod (both of which use QuickTime) only show the video and no sound.
iPod plays video but not audio of some exported files
http://docs.info.apple.com/article.html?artnum=302588
One way to work around this is to use MPEG Streamclip to convert the files to fix this issue...
http://www.squared5.com/
Frequently asked questions about viewing and syncing video with iTunes and iPod
http://docs.info.apple.com/article.html?artnum=302758
GUIDES TO: Converting Video for iPod - Mac & Window
http://forums.ilounge.com/showthread.php?s=&threadid=123067
Patrick -
Why is there no WSDL type support for Web Api?
So I am just getting started with .Net WebApi and one thing that I am noticing straight away is that there is no Contract defining how the Api looks and should be consumed (Request/Responses from each Action), this is usually in the form of a WSDL for WCF/Soap.
It seems to me like this is something that would be very valuable and make life a lot easier for consumers of your Api.
Is there a reason there isn't one? Is there a programming paradime or principle that I am unaware of? Is there a way I could create one?SOAP, REST AND PEOPLE'S CREATIVITY
SOAP needs a description document like WSDL because each resource can be consumed with different messages, there are no definition on the protocol about constraints to the possible names/messages that you can manipulate a resource.
For example, in SOAP your web service that allow clients manipulate an user can expose the operation that create an user in many different messages, like:
addUser
createUser
insertUser
Of course, these are just few sample messages, because I've see a lot of funny web services method names. There are really creative people out there.
In other hand, if you are exposing your underlying system using web api that really respect the REST principles, the client just need to know that you have a resource named Users, because there is 99% of chance that you can create an user in this way
POST /Users
And this occurs for each operation you want to expose using SOAP or a web api REST.
Despite being SOAP a protocol, which restricts what you can or can not do, and be REST a style architecture, which leaves many open points of how to do things. There are efforts to define conventions of how to expose and consume REST web apis.
DESCRIBING A WEB API REST
In the field of how to describe a web api REST I can cite
Swagger. It is not a attempt to create a WSDL like to web api REST, but it is a good attempt to create an open standard for describing web apis REST.
Swagger is a specification and complete framework implementation for describing, producing, consuming, and visualizing RESTful web services.
I use Swagger a lot and really love it, mainly because
Swagger UI that allow you generate a nice live console and documentation for your web api.
There are many implementations of Swagger for most of languages: C#, Java, Python, Ruby, etc.
If you are using ASP .NET Web API, there a some projects to auto generate the Swagger specification, like
Swagger.NET
GENERATING CLIENTS TO A WEB API REST
Because the constraints of REST, like the limited set of verbs (GET, POST, PUT, DELETE, etc) is not so difficuty to generate a client library to a web api REST.
Projects like
WebApiProxy can easily generate clients do C# and Javascript.
CONVENTIONS FOR WEB API REST
To keep our lifes as developers easier is good define some conventions of how our web api REST will behave, the best effort I know in this field is the very good
Apigee - Web Api Design ebook. The e-book is not an attempt to create a bible or a mantra about how to design your api, but rather a collection of conventions observed in large web REST apis, like Twitter, Facebook, Linkedin, Google, etc. -
Are mutliple database calls really significant with a network call for a web API?
At one of my employers, we worked on a REST (but it also applies to SOAP) API. The client, which is the application UI, would make calls over the web (LAN in typical production deployments) to the API. The API would make calls to the database.
One theme that recurs in our discussions is performance: some people on the team believe that you should not have multiple database calls (usually reads) from a single API call because of performance; you should optimize them so that each API call has only
(exactly) one database call.
But is that really important? Consider that the UI has to make a network call to the API; that's pretty big (order of magnitude of milliseconds). Databases are optimized to keep things in memory and execute reads very, very quickly (eg. SQL Server loads and
keeps everything in RAM and consumes almost all your free RAM if it can).
TLDR: Is it really significant to worry about multiple database calls when we are already making a network call over the LAN? If so, why?
To be clear, I'm talking about order of magnitude -- I know that it depends on specifics (machine hardware, choice of API and DB, etc.) If I have a call that takes O(milliseconds), does optimizing for DB calls that take an order of magnitude less, actually
matter? Or is there more to the problem than this?
Edit: for posterity, I think it's quite ridiculous to make claims that we need to improve performance by combining database calls under these circumstances -- especially
with a lack of profiling. However, it's not my decision whether we do this or not; I want to know what the rationale is behind thinking this is a correct way of optimizing web API calls.But is that really important? Consider that the UI has to make a network call to the API; that's pretty big (order of magnitude of milliseconds). Databases are optimized to keep things in memory
and execute reads very, very quickly (eg. SQL Server loads and keeps everything in RAM and consumes almost all your free RAM if it can).
The Logic
In theory, you are correct. However, there are a few flaws with this rationale:
From what you stated, it's unclear if you actually tested / profiled your app. In other words, do you actually know that
the network transfers from the app to the API are the slowest component? Because that is intuitive, it is easy to assume that it is. However, when discussing performance, you should never assume. At my employer, I am the performance lead. When I first joined,
people kept talking about CDN's, replication, etc. based on intuition about what the bottlenecks must be. Turns out, our biggest performance problems were poorly performing database queries.
You are saying that because databases are good at retrieving data, that the database is necessarily running at peak performance, is being used optimally, and there is nothing that can be done
to improve it. In other words, databases are designed to be fast, so I should never have to worry about it. Another dangerous line of thinking. That's like saying a car is meant to move quickly, so I don't need to change the oil.
This way of thinking assumes a single process at a time, or put another way, no concurrency. It assumes that one request cannot influence another request's performance. Resources are shared,
such as disk I/O, network bandwidth, connection pools, memory, CPU cycles, etc. Therefore, reducing one database call's use of a shared resource can prevent it from causing other requests to slow down. When I first joined my current employer, management believed
that tuning a 3 second database query was a waste of time. 3 seconds is so little, why waste time on it? Wouldn't we be better off with a CDN or compression or something else? But if I can make a 3 second query run in 1 second, say by adding an index, that
is 2/3 less blocking, 2/3 less time spent occupying a thread, and more importantly, less data read from disk, which means less data flushed out of the in-RAM cache.
The Theory
There is a common conception that software performance is simply about speed.
From a purely speed perspective, you are right. A system is only as fast as its slowest component. If you have profiled your code and found that the Internet is the slowest component, then everything else is obviously not the slowest part.
However, given the above, I hope you can see how resource contention, lack of indexing, poorly written code, etc. can create surprising differences in performance.
The Assumptions
One last thing. You mentioned that a database call should be cheap compared to a network call from the app to the API. But you also mentioned that the app and the API servers are in the same LAN. Therefore, aren't both of them comparable as network calls? In
other words, why are you assuming that the API transfer is orders of magnitude slower than the database transfer when they both have the same available bandwidth? Of course the protocols and data structures are different, I get that, but I dispute the assumption
that they are orders of magnitude different.
Where it gets murkey
This whole question is about "multiple" versus "single" database calls. But it's unclear how many are multiple. Because of what I said above, as a general rule of thumb, I recommend making as few database calls as necessary. But that is
only a rule of thumb.
Here is why:
Databases are great at reading data. They are storage engines. However, your business logic lives in your application. If you make a rule that every API call results in exactly one database call, then your business logic may end up in the database. Maybe that
is ok. A lot of systems do that. But some don't. It's about flexibility.
Sometimes to achieve good decoupling, you want to have 2 database calls separated. For example, perhaps every HTTP request is routed through a generic security filter which validates from the DB that the user has the right access rights. If they do, proceed
to execute the appropriate function for that URL. That function may interact with the database.
Calling the database in a loop. This is why I asked how many is multiple. In the example above, you would have 2 database calls. 2 is fine. 3 may be fine. N is not fine. If you call the database in a loop, you have now made performance linear, which means it
will take longer the more that is in the loop's input. So categorically saying that the API network time is the slowest completely overlooks anomalies like 1% of your traffic taking a long time due to a not-yet-discovered loop that calls the database 10,000
times.
Sometimes there are things your app is better at, like some complex calculations. You may need to read some data from the database, do some calculations, then based on the results, pass a parameter to a second database call (maybe to write some results). If
you combine those into a single call (like a stored procedure) just for the sake of only calling the database once, you have forced yourself to use the database for something which the app server might be better at.
Load balancing: You have 1 database (presumably) and multiple load balanced application servers. Therefore, the more work the app does and the less the database does, the easier it is to scale because it's generally easier to add an app server than setup database
replication. Based on the previous bullet point, it may make sense to run a SQL query, then do all the calculations in the application, which is distributed across multiple servers, and then write the results when finished. This could give better throughput
(even if the overall transaction time is the same).
TL;DR
TLDR: Is it really significant to worry about multiple database calls when we are already making a network call over the LAN? If so, why?
Yes, but only to a certain extent. You should try to minimize the number of database calls when practical, but don't combine calls which have nothing to do with each other just for the sake of combining them. Also, avoid calling the database in a loop at all
costs. -
Export data to excel with EPPlus and Web Api - HELP!
I am trying to do a simple excel file export with EPPlus and Web Api. In the html client I have a button that calls the web api and opens a new window. No error is thrown, but the result is always "file could not be downloaded". I get the
save file dialog but the file name is Order/ instead of the expected Orders.xls or Orders.xlsx. Can anyone help? I'm surprised this is so difficult.
using System.Linq;
using System.Net.Http;
using System.Web.Http;
using OfficeOpenXml;
using System.Collections.Generic;
using System.IO;
using System.Net.Http.Headers;
using System.Net;
using System.ComponentModel.DataAnnotations;
namespace LightSwitchApplication
public class OrdersController : ApiController
// GET: api/Orders
[HttpGet]
public HttpResponseMessage Get()
HttpResponseMessage response;
response = Request.CreateResponse(HttpStatusCode.OK);
MediaTypeHeaderValue mediaType = new MediaTypeHeaderValue("application/octet-stream");
response.Content = new StreamContent(GetExcelSheet());
response.Content.Headers.ContentType = mediaType;
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
response.Content.Headers.ContentDisposition.FileName = "Orders.xls";
return response;
public List<Order> GetOrders()
List<Order> colOrders = new List<Order>();
using (ServerApplicationContext ctx = ServerApplicationContext.Current ??
ServerApplicationContext.CreateContext())
colOrders = ctx.DataWorkspace.Data.Orders.GetQuery().Execute().ToList();
return colOrders;
public MemoryStream GetExcelSheet()
using (var package = new ExcelPackage())
var worksheet = package.Workbook.Worksheets.Add("Orders");
worksheet.Cells["A1"].LoadFromCollection(GetOrders(), false);
package.Save();
var stream = new MemoryStream(package.GetAsByteArray());
return stream;
This has been driving me crazy for two days!Making some progress. I got the spreadsheet into a byte[] and used code from Paul Van
Bladel's blog to make the HttpResponseMessage. If I comment out the LightSwitch data access code, this works to export a spreadsheet from a static list to the browser from Web Api.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web.Http;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Details;
using OfficeOpenXml;
using System.ComponentModel.DataAnnotations;
namespace LightSwitchApplication
public class Order
[Key]
public int Id { get; set; }
public string OrderNumber { get; set; }
public class OrdersController : ApiController
// GET: api/Orders
[HttpGet]
public HttpResponseMessage Download()
MediaTypeHeaderValue mediaType =
MediaTypeHeaderValue.Parse("application/octet-stream");
byte[] excelFile = ExcelSheet();
string fileName = "Orders.xlsx";
MemoryStream memoryStream = new MemoryStream(excelFile);
HttpResponseMessage response =
response = Request.CreateResponse(HttpStatusCode.OK);
response.Content = new StreamContent(memoryStream);
response.Content.Headers.ContentType = mediaType;
response.Content.Headers.ContentDisposition =
new ContentDispositionHeaderValue("fileName") { FileName = fileName };
return response;
public List<Order> Orders()
List<Order> orders = new List<Order>();
orders.Add(new Order { Id = 1, OrderNumber = "123456789" });
orders.Add(new Order { Id = 2, OrderNumber = "987654321" });
return orders;
// this doesn't work
//public List<Order> Orders()
// List<Order> colOrders = new List<Order>();
// using (ServerApplicationContext ctx = ServerApplicationContext.Current ??
// ServerApplicationContext.CreateContext())
// colOrders = ctx.DataWorkspace.Data.Orders.GetQuery().Execute().ToList();
// return colOrders;
public byte[] ExcelSheet()
using (var package = new ExcelPackage())
var worksheet = package.Workbook.Worksheets.Add("Orders");
worksheet.Cells["A1"].LoadFromCollection(Orders(), false);
byte[] bytes = package.GetAsByteArray();
return bytes;
The problem is that the LightSwitch query (commented out in the code above) is trying to load navigation properties for the orders. Error: "It is not valid to access this object on the current thread." How do I solve this? -
Premiere Elements 9 disk has no .exe file?
My Premiere Elements disk has no .exe file. I know this because I had it installed on my old PC thanks to the help I received from Adobe. I now need it on my new PC, some help would be appreciated please?
vere clarke
I do not fully understand the situation you are in with the disc that you presently have....
a. why you cannot use AutoPlay to install from the disc
b. if you do not want to do "a", why you cannot copy the installation disc to the computer and then use the Setup.exe file.
Lots of questions to get your installation disc usable, but....
To cut to a quick solution to your problem, provided you have a purchased serial number for Premiere Elements 9....
Go to the following web site and download and install the Premiere Elements 9 tryout. During installation of this tryout, insert
your purchased serial number to make it your working copy. The key to success in this particular route is to read and carry out
carefully the web site's "Note: Very Important Instructions" and its click "here" so that you do not run into Access Denied.
Photoshop Elements 9 & Premiere Elements 9 Direct Download Links | ProDesignTools
Please let us know the outcome.
Thank you.
ATR -
Semantic Logging web api in web role
Hi Team,
I have implemented web api with semantic logging to capture logs and hosted in azure.
I have azure project added the web api project as existing web role project.
Below are my code snippet.
In eventsource class:
[Event(1, Level = EventLevel.Informational, Keywords = Keywords.BRRIHUB, Task = Tasks.Processing, Opcode = Opcodes.Debug, Version=1)]
public void DebugLogging(string msg)
if (IsEnabled())
this.WriteEvent(1, msg);
In web api controller:
using Microsoft.Practices.EnterpriseLibrary.SemanticLogging;
using Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Formatters;
[HttpPost]
public string DebugLogging(HttpRequestMessage Req)
string Response = null;
EventListener DebugLogFileListener = null;
try
DebugLogFileListener = FlatFileLog.CreateListener(localResource.RootPath + "DebugLog" + System.DateTime.UtcNow.ToString("MMddyyyy") +
".txt", formatter: new XmlEventTextFormatter(EventTextFormatting.Indented), isAsync: true);
DebugLogFileListener.EnableEvents(BRRIHubEventSource.Log, EventLevel.Informational, BRRIHubEventSource.Keywords.BRRIHUB);
string msg = Req.Content.ReadAsStringAsync().Result;
BRRIHubEventSource.Log.DebugLogging(msg);
Response = "Message Successfully written in to Debug log File";
catch (Exception ex)
Response = "Error in writting Debug log File" + ex.Message;
finally
DebugLogFileListener.Dispose();
return Response;
In webrole onstart to synchronize the log files written in resource folder to azure container:
LocalResource localpath = RoleEnvironment.GetLocalResource("LogStorage");
var logFilePath = localpath.RootPath;
var logDir = new DirectoryConfiguration
Container = "slab-logs",
DirectoryQuotaInMB = 100,
Path = logFilePath
var diagnostics = DiagnosticMonitor.GetDefaultInitialConfiguration();
diagnostics.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
diagnostics.Directories.DataSources.Add(logDir);
var connStr = CloudConfigurationManager.GetSetting("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString");
DiagnosticMonitor.StartWithConnectionString(connStr, diagnostics);
But this code is running fine from my local machine.
After deploying it to azure this is not running as expected. First time it is creating log files in resource folder. but then later it is keep sending error message like below,
- The operation has timed out
- File used by another process
How can I resolve this? Kindly experts please share your ideas and blogs that available for writing semantic logs file in flat file and then it should move to azure storage blob container.
Expect azure experts advise.
Thanks.Hi Billgiee,
Thanks for replying. I have tested by taking RDP of instance deployed.
Finally I found the issue fix. This was happen due to created file listener in asynchronous mode. After I changed that property to false. Code is working fine. now it is continuously taking the input and writing to log files in semantic logging approach.
Set property : isAsync: false
It got fixed!
Coding snippet:
DebugLogFileListener = FlatFileLog.CreateListener(localResource.RootPath + "DebugLog" + System.DateTime.UtcNow.ToString("MMddyyyy") + ".txt", formatter: new XmlEventTextFormatter(EventTextFormatting.Indented), isAsync:
false);
Thanks
Thanks, SaravanaBharathi.A -
How to call a Web Api from from a Visual webpart code behind?
Hi,
I am trying to create a visual web part in sharepoint 2013 with data received from another Web API.
I followed the below steps.
1. Created a Visual Web part.
2. In the code behind(.cs) file I wrote the following code.
async private void GetResult()
using (var client = new HttpClient())
client.BaseAddress = new Uri("http://localhost:8080/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = await client.GetAsync("api/Tfs/OpenEnquiriesCount");
var content = response.Content;
3. When I run the application, I get security exception in the line await
client.GetAsync()
What is the way to achieve this? How to call a web api from share point visual web part?
Thank you in advance.Hi,
Thanks for your sharing.
Cheers,
Jason
Jason Guo
TechNet Community Support
Maybe you are looking for
-
I'm hoping to sync iCal via my four apple devices through the iCloud. Unfortunately, I used two different Apple IDs when setting up the iCloud accounts on the devices. How can I change the Aplle ID associated with my iPhone so that it's the same one
-
Transfer files from one directory to another using HTTPS message protocol
My client has an requirement where the source files are in different directory and they need to be placed in a target directory with the same filename..it looked simple so far... but the actual complexity is that the source files are on a Novell serv
-
I possess a badge mother K7N2 Delta-L and I have problems with the DVD and the CDRW. I Have connected the hard disk as master primary ,CDRW as primary slave and the DVD like secondary master. My os. it is Win XP and there are times that the units CD
-
Sun Webserver 7.0 Tech Preview - Provisioning VSs with extra variables.
Hi, In my environment, I need to set an additional variable 'siteroot' on each virtual server. This is used with some pfx2dir directives in obj.conf. Is there a way to do this via the CLI (i.e. wadm). I note there's a set-virtual-server-prop command
-
Hi I have an IPAD 2 and am planning a trip to Budapest, Hungary, I use Verizon, will I be able to use the Ipad 2 in Budapest? Thank you.