.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT
Post New Web Links

How is HttpPostedFile.ContentType determined?

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :ASP.Net

How does .NET 3.5 determine what the correct HttpPostedFile.ContentType value is? The MSDN library document doesn't specify how this is done. Is it based on the client's list of known MIME types, the server's list, or something else altogether?

View Complete Post

More Related Resource Links

SPSiteDataQuery not working for ContentType

Could someone help me figure out why this is not working?  I am trying to use a SPSiteDataQuery object to return all documents in all document libraries in a site collection, excluding folders.  The query works fine in U2U Caml Query Builder but when i run it using the SPSiteDataQuery class it is returning folders and documents.  Sometimes it crashes on the GetSiteData call, but that seems to be another problem related to the MFP_Group column, which is a managed metadata site column.  Here is my code: Using web As SPWeb = OpenWeb(sSite) Dim oQuery As New SPSiteDataQuery oQuery.Lists = "<Lists ServerTemplate='101' />" oQuery.ViewFields = "<FieldRef Name='Title' />" & _ "<FieldRef Name='Project_x0020_Number' Nullable='TRUE' Type='Text'/>" & _ "<FieldRef Name='ContentType'/>" & _ "<FieldRef Name='Project_x0020_Status' Nullable='TRUE'/>" & _ "<FieldRef Name='FileRef' Nullable='TRUE'/>" & _ "<FieldRef Name='Pegasys_x0020_Ref_x0020_Number' Nullable='TRUE'/>" & _ "<FieldRef Name='MFP_x0020_Group' Nullable='TRUE'/>"  oQuery.Query = "<Where><Neq><FieldRef Name='ContentType'/><Value Type='Text'>Folder</Value><

Problem when deployind ContentType: Error occurred in deployment step 'Activate Features': Field t

Im getting this error when i try to Deploy my ContenType: Error occurred in deployment step 'Activate Features': Field type GUID is not installed properly. Go to the list settings page to delete this field Does someone know how to fix this error? The ContentType is defined as: <     Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <!--Site columns--> <Field Name="Test" DisplayName="Customer Subject ID" ID="{38A9E5BA-62FF-4F3B-90E3-F9961FEABE20}" Type="Text" Required="FALSE" /> <!--Parent ContentType: Item (0x01) --> <ContentType ID="0x01004317ec735b25468583d7470aa17c36ae" Name="NextContentTypes - NextCustomerContentType" Group="Next Content     Types"Description="NextCustomerContentType" Inherits="TRUE" Version="0"> <FieldRefs> <!-- References to field difinitions --> <FieldRef ID="{38A9E5BA-62FF-4F3B-90E3-F9961FEABE20}" Name="Test"></FieldRef> </FieldRefs> </ContentType> </     Elements>

Deploy Error on contentType.UpdateWorkflowAssociation(wfAssociation);

I am using vs.net 2010 and deploying my feature which includes a workflow. I am getting the following error "Error 5 Error occurred in deployment step 'Activate Features': There is already a workflow association with this name 'Test Level'" This error is occurring on the following line contentType.UpdateWorkflowAssociation(wfAssociation);  If I remove the attempt to update the workflow association it deploys ok.  Also, if i remove the deployment site and recreate it so that there isn't a workflow association it works ok as well. Why am I getting this error on contentType.UpdateWorkflowAssociation(wfAssociation) ??   thanksdave

Is there a way to determined to have a stable connection between my applicatio and WCF/asmx?

Is there a way to determined to have a stable connection between my applicatio and WCF/asmx?3 stars and a sun

best practice validation contenttype

hi, I'm working on and custom Schedule contenttype where I need to add and customer/s from and other list (and lookup field with multiple values). Now I need to validate the selected customer/s with the schedule so they do not get double reservations > check if the customer has and reservation on that day. Whats you advice to do this? I was looking at and custom field but I only need it in this contenttype. thanks steve

How to set Page title for Response.ContentType = "image/jpeg"

Hi , how can i set Title for a page with Response.ContentType = "image/jpeg" ? thanks, Naresh

Changing ContentType in Workflow using vs2008


Hi Everyone,

I need to change the ContentType in my Sharepoint workflow. If I set the following will this change it? If not how. If I am presently using ContentType 1 for a List and want to switch to using ContentType 2 what code do I need in order to make this happen?

SPListItem currentItem = workflowProperties.Item;
SPContentType myCType = workflowProperties.List.ContentTypes["ContentType 2"];

    currentItem["ContentTypeId"] = myCType.Id;

I'm thinking this will work but not sure.



Process must exit before requested information can be determined...


Hello All!

I wrote the following lines of code within the even handler for a Process_Exited event. The really weird thing is that on the fifth line I get the error "Process must exit before requested informaiton can be determined. (When trying to access the Exit Time & Exit Code)

            Private Sub AssociatedProcess_Exited(ByVal sender As Object, ByVal e As System.EventArgs) Handles AssociatedProcess.Exited
                Do Until AssociatedProcess.HasExited = True
                'The process has exited.
                Console.CursorLeft = 0
                Console.WriteLine("{0}: {1}. Exit Code: {2} ({3})" & vbCrLf, _
                                  Date.Now, AssociatedProcess.StartInfo.FileName, AssociatedProcess.ExitCode, If(AssociatedProcess.ExitCode = 0, "Success", "Fail"))

Does anyone have any ideas as to why this is happening? I cant make sense of it.

Data Export to Excel file using "Response.ContentType = "application/csv"


I have developed code to export data to Excel using Response.ContentType = "application/csv". The output Data Excel file loaded with 65536 Rows only, this file is not loaded completely since the limitation of excel is 65536. My Recordcount is more than 700000.

Please any one let me know how I can Export Data to Excel file over than 65536 Rows.

Email: thamaraiselvann@ayso.org

The default web application could not be determined. Set the SiteUrl property in feature


I am getting this error when I deploy a BCS feature generated by BCSMetaMan:

The default web application could not be determined. Set the SiteUrl property in feature Feature_Feature1 to the URL of the desired site and retry activation.

Searching the Internet tells me I need to put in a property in my feature file that sets the default site. However, what if I need to be able to deploy this other sites. Is there a way to set the value so it will use whatever site is the solution is being deployed to?

Error 1807 A valid destination folder for the install could not be determined. Trying to install s

Would someone clue me in as to why this error msg pops up?  I have admin rights on the laptop I'm trying to install the app on.  I right clicked on the .msi file but I don't see an option to run as admin.  If you need more info let me know.

Response.ContentType possible values?


I am trying to open a document read from database.  The document can be of any type such as JPG, PDF, EXCEL, WORD, TEXT, etc.  I am wondering what value I should assign to Response.ContentType?  What are the possible values?  Could I just use the following for all file types?


Response.ContentType = "application/octet-stream";

Or should I assign different value for each individual file types?




Contenttype and contentsource unavailable in FullTextSqlQuery


In my 2007 enviroment I was able to build a query like 'SELECT Title, Path, ContentType, ContentSource FROM....'

But I deployed my custom code to a SP2010 environment, updated the obsolete code.

In the 2010 environment I'm unable to use ContentType or ContentSource as select fields...

All my other customer meta data mappings do work.

var proxy = (SearchServiceApplicationProxy)SearchServiceApplicationProxy.GetProxy(SPServiceContext.GetContext(SPContext.Current.Site));
        qry = new FullTextSqlQuery(proxy)
               TrimDuplicates = true,
               EnableStemming = false,
               IgnoreAllNoiseQuery = true,
               ResultTypes = ResultType.RelevantResults,
               QueryText = sql,
               RowLimit = 100

        ResultTableCollection results;
var sb = new StringBuilder();
      sb.Append("SELECT Rank,Title,Path,HitHighlightedSummary,VMMaContentType,");

myFileInput.PostedFile.ContentType equals null?


Simple upload has been working for quite a while now, yet it seems to all the sudden not work (but only for specific file types).  mp3 can upload, flv cannot (remember, this was all working before).

After a little debugging, I discovered that a portion of my code is never being entered because I test something first:

if ((resourceMediaFile.PostedFile != null) && (resourceMediaFile.PostedFile.ContentType != null))

I have discovered that resourceMediaFile.PostedFile is not null, resourceMediaFile.PostedFile.ContentLength is the correct size for the uploaded file, yet resourceMediaFile.PostedFile.ContentType is now null.  I've literally had this work over 1,000 times with several files (including the one I'm testing with) and it consistently came back "application/flv".

What would cause ContentType to be null if the other attributes are not?

Naming contenttype fields




I have started to create new contenttypes for primarily document-libraries.  If stumpled upon that the naming of fields is saved globally which means you cannot use "Topic" more than once globally! So if I would need Topic in 2 different contenttypes I need to be creative and name it "WhateverTopic".

What is the best practice for naming fields when in need of creating different types of fields with the same name on different contenttypes?


ramifications of making contentType hidden

I need to understand the ramifications of putting a site contentype in a hidden group.  I have a custom list that uses that site content type.  This list gets its list items from an external web service and so I do not want the New button to be available to user.  Would the best way to do that be to make a special SharePoint group that only has edit privledges, or putting the ContentType in a hidden group make it so that users cannot create a new item in the list.  I was afraid to put the contenttype in a hidden group because I am uncertain whether that is reversible.
There are no mistakes; every result tells you something of value about what your are trying to accomplish.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend