473,715 Members | 4,902 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding a new MIMEType

8 New Member
Hello der !

at my wits end and cant figure out what is the problem..
my task is to programmaticall y configure IIS , part of which is to add MIMETypes...
after googling for a like a million years , found very little help with regard to this topic..finally managed to write some code but there seems to be some strange error..
following is the function..
Expand|Select|Wrap|Line Numbers
  1. long CWinWebAppController::CreateMimeType(/*[in]*/ const CMimeType& objCMimeType,
  2.                                           /*[out]*/      wstring& strErr)
  3. {
  4.   IADs*                ptrADs         = 0;
  5.   HRESULT              hr             = S_FALSE;
  6.   CComPtr<IISMimeType> ptrMimeType    = 0;
  7.  
  8.   _variant_t vntMimeMap;
  9.  
  10.  
  11.   //Reinitialise the error code
  12.   m_lError                    = 0;
  13.   m_wstrMethodName            = L"CreateMimeType";
  14.   strErr                      = SUCCESS;
  15.  
  16.  
  17.   try
  18.   {
  19.     //Get the handle to the MimeMap 
  20.     hr = ADsGetObject(L"IIS://LocalHost/MimeMap",IID_IADs,(void**) &ptrADs);
  21.     if(FAILED(hr)) 
  22.     {
  23.       strErr = ADS_GETOBJECT_FAILED;
  24.       throw hr;
  25.     }
  26.  
  27.     hr = ptrADs->QueryInterface(IID_IISMimeType, (void **)&ptrMimeType );
  28.     if(FAILED(hr)) 
  29.     {
  30.     }
  31.  
  32.     //Load the property MimeMap
  33.     hr = ptrADs->GetEx(L"MimeMap",&vntMimeMap);
  34.  
  35.  
  36.       SAFEARRAY*  pArrMimeMap ;
  37.       //point the safearray to the array inside the variant..
  38.       pArrMimeMap = vntMimeMap.parray;
  39.  
  40.       //*******************************************************
  41.       long lHigh;
  42.       SAFEARRAY * psa;    // The safearray
  43.       SAFEARRAYBOUND rgsabound[1];    // A one dimensional array
  44.       long * pData;
  45.       long lValue, lIndex;
  46.  
  47.       _variant_t vntNewMimeType;
  48.  
  49.       SafeArrayGetUBound(pArrMimeMap, 1, &lHigh);
  50.  
  51.       rgsabound[0].lLbound = 0;    // With lower bound 0;
  52.       rgsabound[0].cElements = lHigh + 1;
  53.       psa = SafeArrayCreate(VT_BSTR, 1, rgsabound);    
  54.  
  55.       //Copy the existing data into the new one...
  56.       SafeArrayCopyData(pArrMimeMap,psa);
  57.  
  58.       //set the properties of the new mimetype object...
  59.       ptrMimeType->put_Extension((_bstr_t)objCMimeType.GetMimeExtension().c_str());
  60.       ptrMimeType->put_MimeType((_bstr_t)objCMimeType.GetMimeExtension().c_str());
  61.  
  62.       //assign the mime type object to the variant...it is of type IDispatch...
  63.       vntNewMimeType.pdispVal = ptrMimeType;
  64.  
  65.       //put the variant in safe array...
  66.       lIndex = lHigh-1;
  67.  
  68.       SafeArrayPutElement(psa,&lHigh,(void*)&vntNewMimeType);
  69.  
  70.       //now return the newly created safe array in the variant...
  71.       vntMimeMap.parray = psa;
  72.  
  73.       //save the data..
  74.       hr = ptrADs->PutEx(ADS_PROPERTY_UPDATE,L"MimeMap",vntMimeMap);
  75.       if(FAILED(hr)) 
  76.       {
  77.         strErr = GRANT_BY_DEFAULT_FAILED; 
  78.         //LOG_ERROR_MESSAGE(m_wstrClassName,m_wstrMethodName,GRANT_BY_DEFAULT_FAILED);
  79.         throw hr;
  80.       }
  81.  
  82.       //********************************************************
  83.  
  84.  
  85.    }//end try
  86.   CATCH_BLOCK1(m_lError,strErr)
  87.     //delete all the pointers...
  88.   //TRACE_END(m_wstrClassName,m_wstrMethodName)
  89.   return m_lError ;
  90. }

please ignore the various variables used...thats internally used in my class...the problematic part is this line..
Expand|Select|Wrap|Line Numbers
  1. hr = ptrADs->QueryInterface(IID_IISMimeType, (void **)&ptrMimeType );
simple that this line seems, for some reason this line results in linking error with :
unresolved external symbol _IID_IISMimeTyp e (note the extra underscore...th ere is no such word in any of the files...)
specifically on windows 2003 machine. it complies fine on my XP professional machine !!!
the msdn doc states all u need to do is include "IIIS.h" header file which is done , it even finds the IID in the header but failes during linking....

one whole day has been already wasted on this...can someone please tel me what goin on here ?? there is no mention of any lib as well...i thought COM usage didn require any libs to be included in the first place!!!

well the reason i need it to compile in windows 2003 machien is that thsi can only be tested on the test machine(which is 2003 machine)...my dev machien with XP doesn seem to have "properties " as an option when right click on local computer in IIS manager ....properties is required to configure MIME types...which is present in 2003 machines....not in XP...why is that so ???
Apr 2 '09 #1
0 2391

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2269
by: Ryan Paul | last post by:
is there any way to determine the mimetype of a file using ruby? TIA --SegPhault
0
1606
by: arachno | last post by:
Hello ppl, Is anyone can help me to figure out how to add data to TextML server document base? I have attached snipped, which taking XML source from file and adding it to documentbase, but my problem is, that i need to add it on "fly", without touching file system. Cheers, arachno
3
10993
by: GR33DY | last post by:
Hello again, I can see myself becoming a regular feature at the top here ;) When I view my XML page using I.E.6 it displays fine from both my web server and when opened from windows explorer. But when I view it in mozilla 1.7, it displays fine from windows explorer, but when viewed via HTTP from the web server I get the following error; Error loading stylesheet: An XSLT stylesheet does not have an XML mimetype
0
360
by: Alex Duggleby | last post by:
Hi everybody, I'm trying to add some mime types to the local IIS server using some c# code. The code I'm using is: ---snip--- DirectoryEntry _mimeMap =
3
4878
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that the best method? Do you have a sample of how to do this?
1
8965
by: Patrick F | last post by:
I cant figure out what mimetype .aspx pages are, i have been searching thru msdn and the only thing that i found was a way to list all mimetypes installed on the computes, output something like this: Microsoft (R) Windows Script Host Version 5.1 for Windows Copyright (C) Microsoft Corporation 1996-1999. All rights reserved. Total MIME Map Entries: 189 Extension MIME Type
1
2344
by: durayakar | last post by:
Hi, SQL 2005 Reporting services... I get a warning of rsInvalidMIMEType when the MIMEType of my external (http) image is Image/Jpeg or Image/JPEG... posting it here for future reference... MIMEType in SQL 2005 Reporting services is wayy too picky, and is case
0
1235
by: forge1968 | last post by:
I want to handle URLs like this on my IIS site: http://localhost/myapp/REST/foo/1 ('REST/foo/1' doesn't exist - I'll dynamically create the content). I have implemented my own VirtualPathProvider and VirtualFile classes to do this. However, the mimetype of the response is 'application/ octet-stream'. I want it to be 'text/xml'. Changing HttpContext.Current.Response.ContentType does not affect the
4
7721
by: th1421 | last post by:
Hi, I'm new to FireFox. I am currently trying to convert my website to be compatible with it. Doing so I’m trying to process some XML/XSLT pages (preferably without using JavaScript). When I view my XML pages using IE 6 or 7 it displays beautifully both accessed locally as through HTTP on my ISP’s server where I put them using FTP. When I view them in Mozilla FireFox 2.0, it displays ok when accessed locally. The CSS presentation –...
0
8821
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
7973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6646
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5967
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4477
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3175
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2539
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2118
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.