Parsing A String To Determine It's A Website URL?
Oct 26, 2010In ASP.net what's the best way I can parse a string to determine if it's a valid URL?
View 2 RepliesIn ASP.net what's the best way I can parse a string to determine if it's a valid URL?
View 2 RepliesI am getting a string in the following format in the query string:
"Arnstung%20Chew(20)"
I want to convert it to just "Arnstung Chew". How do I do it?
Also how do I make sure that the user is not passing a script or anything harmful in the query string?
[Code]....
tring value from front and back
I have an object called Time
public class Time{
public int Hour {get;set;}
public int Minute {get;set;}
public static Time Parse(string timeString){
//reads the ToString()'s previous output and returns a Time object
}.....
So what I want is for the automatic model binding on the Edit or Create action to set this Time instance up from a string (i.e. feed the Parse method with the string and return the result).
The reason I am doing this is that I will have a DropDownList with selectable times. The value of each option will be the parser readable string.
I'm writing a class to automatically extract information from an excel spreadsheet (using NPOI api) in C#, and then import this information into a database. I've got it all working fine except for one small issue.
One of the spreadsheets I'm working with, contains the date in the following format: 04/01/2011 04:43:28.
When I ran the web application, I got the following error message:
String was not recognised as a valid
So I debugged through the code after this, and it turns out that the date is being read in as:
40546.0151388889, so it is being formattted back to a number.
[code]....
I'm developing an sms application in c#. The service that I use to send a message only allows characters form the 7 bit alphabet. I'm looking for a way to check if a message only contains characters from this alphabet.
My first idea was to split the message into a character array and then loop these characters and compare them to the alphabet. But I bet there is a much better.
7 big alphabet:
[URL]
How determine if a string has been encoded programmatically in C#?
Lets for example string:
<p>test</p>
I would like have my logic understand that this value it has been encoded..
I have a list of strings:
var listOfStrings = new List<string>{"Cars", "Trucks", "Boats"};
and I have a vehicles options which has a Name field.I want to find the vehicles where the name matches one of the items in the listOfStrings.I'm trying to do this with linq but can't seem to finish it at the moment.
var matchingVehicles = Vehicles.Where(v => v.Name == one of the listOfStringItem)
point me towards any .NET API that will let me iterate the default documents (default.aspx, index.html, etc.) for the web site? I know I can parse web.config, but that doesn't always contain all of the default documents.
View 1 RepliesI've set up IIS7 on my home computer and have written a very basic ASP.NET website to be deployed on this webserver. Everything works great. How do I determine programmatically the physical path (for instance, "C:inetpub_MyWebsite") of the website? I need to write an XML file to the website's root folder dynamically and therefore need to know the folder's physical location.
View 3 RepliesIs there a method anywhere in the .NET framework or System.Web that will tell me whether a string contains an HTML or is one?
Should I just Server.HtmlEncode(myString) and see if its length is longer than myString's length before encoding?
I want design a page where the end user enters information on my page and related information is fetched from the another website on my web page.
For example: Capturing City and state name from USPS.com
End user Task : Enter zipcode and click button 'Fetch'
My page perform few task
1. opens usps site backend
2. Enters the zipcode
3. Captures city name and state as temporary value from the usps
4. Displays the same in labels present in my home page.
I have an ASP.net/VB.net website, and want to make an inquiry of another website to obtain particular information for use on my site in string format. For example, I have used the code:
Result01 = "http://api.hostip.info/get_html.php?ip=" + Variable01
which only produces the other website address as a string. However, I want to get the actual result of the inquiry as a string. I have experimented with System.Xml.XmlDocument coding, without any luck. the proper coding to get the results of such an inquiry as a string?
In one of my ASP.Net websites, I have to provide a link to the user in which all query string parameters should be encrypted.What I am thinking is to use the command "aspnet_regiis" (as used to encrypt web.config data), pass output as a query string inside published url.When the user clicks that link, I first decrypt the string and then fetch the original data for the query string.Am right in doing this? Is there any good technique to encrypt and decrypt query strings?
View 4 RepliesI have a large(ish) text-box on my page that needs to hold a website URL. The text-box is reasonably wide however most URLs will not fit in on a single line. I want the website address to wrap a single line like this:
[URL]
However what my textbox is doing is this:
[URL]
Does anyone know how to automatically wrap a string that does not contain line feeds / white space? (Yes - Wrap is set to true!)
I have a xml file having the tags like
<link>
<linkto>[URL]/broadcasts/index.cfm?fuseaction=usrbrd&broadcasterid=57468</linkto>
<image>report_button</image>
<alt>Report a Problem</alt>
<target></target>
</link>
<linkto> tag have the url. But because of the "&" symbol in the url thats completely crashing the page. I tried using like amp; next to the & symbol but this doesn't give the correct url.
This is the connection string that gets generated with the "New ASP.Net Website" template in vs 2010
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
I have a named instance of sql 2008 developer edition installed. I have changed the Server name but the query string will still not work. I want to be able to use the default db "aspnetdb.mdf". I use Windows authentication to connect. How can i change the connection string to get this to work?
I am in trouble. I have a asp.net file and publish it and run in localhost. [URL]. Its working fine.
But i put the file in mob server(It's the own server we are using in my concern)[URL] its not working. I got an error message that is
XML Parsing Error: not well-formed
Location: file://///Mob/mdirectalpha/CPWebserviceAlpha/Addons.asmx
Line Number 1, Column 2:<%@ WebService Language="C#" CodeBehind="~/App_Code/Addons.cs" Class="Addons" %>
-^
Is it the problem in server? I need to set any settings in server?
I'm developing a small ASP.NET Mvc project in Mono 2.4, Ubuntu 10.10. There is an array of objects, each one of them corresponds to a certain xml file. Reading of the xmls is performed with XmlTextReader. That does not work because xml files have rare "cp866nav" encoding, which is not supported by XmlTextReader ("System.ArgumentException: Encoding name 'cp866nav' not supported"). But it works fine if encoding in xml header is changed to "cp866". I found a kind of solution which consists in initializing XmlTextReader with a StreamReader with a certain encoding instead of file name, like in the code below:
XmlTextReader reader = new XmlTextReader(new StreamReader(Server.MapPath(filename), Encoding.GetEncoding("cp866")));
The issue is that the directory which contains xml files is read only (I can not change it), so I get "System.UnauthorizedAccessException: Access to the path '' is denied.". Rather strange, because XmlTextReader initialized with a filename seems to read the files. Is there any solution, considering that program cannot modify or create files?
I'm working on two pages using VB. The 1st page have a textbox to key in the names. And the 2nd page will have a label to display the text thats entered in the previous page.
View 3 RepliesI am working with Yahoo map in asp.net MVC .I want to show pushpin and load map with latitude and longitude saves in database.I am using following jQuery script
<script
type="text/javascript">
$(document).ready(
[code]...
I have a ViewModel class: "MainPage" which contains 2 properties: Title, Id.I have a controller which prepares a list of MainPage and sends it to the view:
public ActionResult SideMenu()
{
MainPageDal dal = new MainPageDal();
DataTable dt = new DataTable();
dt = dal.GetArticlesList();
List<MainPage> mainPageList = new List<MainPage>();
MainPage mainPage;
foreach (DataRow row in dt.Rows)
{
mainPage = new MainPage(Convert.ToInt16(row["Id"]), row["Title"].ToString());
mainPageList.Add(mainPage);
}
return View(mainPageList);
}
In my view I do:
<% foreach (var mainPage in Model) { %>
Now I added "List<String> myList=new..." into my MainPage class and tried to do foreach like this:
Why I can't do: <% foreach (var str in Model.myList) { %>
myList is a list of string inside MainPage.The error I get is:
c:devMvcTestMvcTestViewsHomeSideMenu.aspx(12): error CS1061: 'System.Collections.Generic.IEnumerable<MvcTest.ViewModels.MainPage>' does not contain a definition for 'myList' and no extension method 'myList' accepting a first argument of type 'System.Collections.Generic.IEnumerable<MvcTest.ViewModels.MainPage>'
could be found (are you missing a using directive or an assembly reference?)
In a situation where we accidentally published an asp.net website, without updatability, with one wrong URL, we'd like to just open that DLL and change the URL, to prevent waiting another week for the next publish opportunity.
In oldish native DLLs I knew how to change resources, but how would I attempt this with .NET DLLs? And is there an easy way, or only a hackerish one (I know of ildasm and ilasm)? If it matters, the string is a literal inside an event handler.
I am reading XML file in the following code
[Code]....
when my xml file is big, I get the following error unexpected end of file while parsing name has occurred. Line 1, position 2034 the xmlData debug showed that not all the xml file is being read
[Code]....
I read that the memory of the string variable is not big enough to handle the xml file, what can I use to be able to read big xml files. my program works for small xml text.
I am building a website and recently I had to format my re-install everything on my lappy..before that the site was working very good locally..but after re-installing VS2008 I don't know why I keep getting this error
XML Parsing Error: no element found
Location: [URL]
Line Number 1, Column 1:
I searched online..and found out that the reason might be some unclosed HTML tag but I checked and made sure that all the tags are properly closed..I also added Response.ContentType = "text/HTML"into .cs files in Pge_Load method..but I am still getting that error..I have one master page and two pages rendered using it..I dont understand how come the same program works once and after re-installing VS it doesn't work I dont know if this will help or not but master page starts with these 3 lines
[Code]....